LLVM  12.0.0git
Classes | Namespaces | Macros | Functions | Variables
OpenMPOpt.cpp File Reference
#include "llvm/Transforms/IPO/OpenMPOpt.h"
#include "llvm/ADT/EnumeratedArray.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
Include dependency graph for OpenMPOpt.cpp:

Go to the source code of this file.

Classes

struct  ICVValue
 Helper struct to store tracked ICV values at specif instructions. More...
 
struct  llvm::DenseMapInfo< ICVValue >
 

Namespaces

 llvm
 This class represents lattice values for constants.
 

Macros

#define DEBUG_TYPE   "openmp-opt"
 
#define ICV_RT_SET(_Name, RTL)
 
#define ICV_RT_GET(Name, RTL)
 
#define ICV_DATA_ENV(Enum, _Name, _EnvVarName, Init)
 
#define OMP_TYPE(VarName, ...)
 
#define OMP_ARRAY_TYPE(VarName, ...)
 
#define OMP_FUNCTION_TYPE(VarName, ...)
 
#define OMP_STRUCT_TYPE(VarName, ...)
 
#define OMP_RTL(_Enum, _Name, _IsVarArg, _ReturnType, ...)
 
#define OMP_RTL(_Enum, _Name, ...)
 

Functions

 STATISTIC (NumOpenMPRuntimeCallsDeduplicated, "Number of OpenMP runtime calls deduplicated")
 
 STATISTIC (NumOpenMPParallelRegionsDeleted, "Number of OpenMP parallel regions deleted")
 
 STATISTIC (NumOpenMPRuntimeFunctionsIdentified, "Number of OpenMP runtime functions identified")
 
 STATISTIC (NumOpenMPRuntimeFunctionUsesIdentified, "Number of OpenMP runtime function uses identified")
 
 STATISTIC (NumOpenMPTargetRegionKernels, "Number of OpenMP target region entry points (=kernels) identified")
 
 STATISTIC (NumOpenMPParallelRegionsReplacedInGPUStateMachine, "Number of OpenMP parallel regions replaced with ID in GPU state machines")
 
template<typename CBTy >
static void foreachUse (Function &F, CBTy CB, bool LookThroughConstantExprUses=true)
 Apply CB to all uses of F. More...
 
 INITIALIZE_PASS_BEGIN (OpenMPOptLegacyPass, "openmpopt", "OpenMP specific optimizations", false, false) INITIALIZE_PASS_END(OpenMPOptLegacyPass
 

Variables

static cl::opt< boolDisableOpenMPOptimizations ("openmp-opt-disable", cl::ZeroOrMore, cl::desc("Disable OpenMP specific optimizations."), cl::Hidden, cl::init(false))
 
static cl::opt< boolPrintICVValues ("openmp-print-icv-values", cl::init(false), cl::Hidden)
 
static cl::opt< boolPrintOpenMPKernels ("openmp-print-gpu-kernels", cl::init(false), cl::Hidden)
 
static constexpr auto TAG = "[" DEBUG_TYPE "]"
 
 openmpopt
 
OpenMP specific optimizations
 
OpenMP specific false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "openmp-opt"

Definition at line 33 of file OpenMPOpt.cpp.

Referenced by llvm::DenseMapInfo< ICVValue >::isEqual().

◆ ICV_DATA_ENV

#define ICV_DATA_ENV (   Enum,
  _Name,
  _EnvVarName,
  Init 
)
Value:
{ \
auto &ICV = ICVs[Enum]; \
ICV.Name = _Name; \
ICV.Kind = Enum; \
ICV.InitKind = Init; \
ICV.EnvVarName = _EnvVarName; \
switch (ICV.InitKind) { \
case ICV_IMPLEMENTATION_DEFINED: \
ICV.InitValue = nullptr; \
break; \
case ICV_ZERO: \
ICV.InitValue = ConstantInt::get( \
Type::getInt32Ty(OMPBuilder.Int32->getContext()), 0); \
break; \
case ICV_FALSE: \
ICV.InitValue = ConstantInt::getFalse(OMPBuilder.Int1->getContext()); \
break; \
case ICV_LAST: \
break; \
} \
}
static Constant * getFalse(Type *Ty)
For a boolean type or a vector of boolean type, return false or a vector with every element false...

◆ ICV_RT_GET

#define ICV_RT_GET (   Name,
  RTL 
)
Value:
{ \
auto &ICV = ICVs[Name]; \
ICV.Getter = RTL; \
}
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name

◆ ICV_RT_SET

#define ICV_RT_SET (   _Name,
  RTL 
)
Value:
{ \
auto &ICV = ICVs[_Name]; \
ICV.Setter = RTL; \
}

◆ OMP_ARRAY_TYPE

#define OMP_ARRAY_TYPE (   VarName,
  ... 
)
Value:
ArrayType *VarName##Ty = OMPBuilder.VarName##Ty; \
(void)VarName##Ty; \
PointerType *VarName##PtrTy = OMPBuilder.VarName##PtrTy; \
(void)VarName##PtrTy;
Class to represent array types.
Definition: DerivedTypes.h:358

◆ OMP_FUNCTION_TYPE

#define OMP_FUNCTION_TYPE (   VarName,
  ... 
)
Value:
FunctionType *VarName = OMPBuilder.VarName; \
(void)VarName; \
PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr; \
(void)VarName##Ptr;
Class to represent function types.
Definition: DerivedTypes.h:108

◆ OMP_RTL [1/2]

#define OMP_RTL (   _Enum,
  _Name,
  _IsVarArg,
  _ReturnType,
  ... 
)
Value:
{ \
SmallVector<Type *, 8> ArgsTypes({__VA_ARGS__}); \
Function *F = M.getFunction(_Name); \
if (declMatchesRTFTypes(F, OMPBuilder._ReturnType, ArgsTypes)) { \
auto &RFI = RFIs[_Enum]; \
RFI.Kind = _Enum; \
RFI.Name = _Name; \
RFI.IsVarArg = _IsVarArg; \
RFI.ReturnType = OMPBuilder._ReturnType; \
RFI.ArgumentTypes = std::move(ArgsTypes); \
RFI.Declaration = F; \
unsigned NumUses = collectUses(RFI); \
(void)NumUses; \
LLVM_DEBUG({ \
dbgs() << TAG << RFI.Name << (RFI.Declaration ? "" : " not") \
<< " found\n"; \
if (RFI.Declaration) \
dbgs() << TAG << "-> got " << NumUses << " uses in " \
<< RFI.getNumFunctionsWithUses() \
<< " different functions.\n"; \
}); \
} \
}
F(f)
static constexpr auto TAG
Definition: OpenMPOpt.cpp:60

◆ OMP_RTL [2/2]

#define OMP_RTL (   _Enum,
  _Name,
  ... 
)
Value:
if (M.getFunction(_Name)) { \
OMPInModule = true; \
break; \
}

◆ OMP_STRUCT_TYPE

#define OMP_STRUCT_TYPE (   VarName,
  ... 
)
Value:
StructType *VarName = OMPBuilder.VarName; \
(void)VarName; \
PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr; \
(void)VarName##Ptr;
Class to represent struct types.
Definition: DerivedTypes.h:218

◆ OMP_TYPE

#define OMP_TYPE (   VarName,
  ... 
)
Value:
Type *VarName = OMPBuilder.VarName; \
(void)VarName;
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46

Function Documentation

◆ foreachUse()

template<typename CBTy >
static void foreachUse ( Function F,
CBTy  CB,
bool  LookThroughConstantExprUses = true 
)
static

Apply CB to all uses of F.

If LookThroughConstantExprUses is true, constant expression users are not given to CB but their uses are traversed transitively.

Definition at line 67 of file OpenMPOpt.cpp.

References llvm::Use::getUser(), llvm::make_pointer_range(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::size(), and llvm::Value::uses().

Referenced by llvm::DenseMapInfo< ICVValue >::isEqual().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( OpenMPOptLegacyPass  ,
"openmpopt"  ,
"OpenMP specific optimizations ,
false  ,
false   
)

◆ STATISTIC() [1/6]

STATISTIC ( NumOpenMPRuntimeCallsDeduplicated  ,
"Number of OpenMP runtime calls deduplicated"   
)

◆ STATISTIC() [2/6]

STATISTIC ( NumOpenMPParallelRegionsDeleted  ,
"Number of OpenMP parallel regions deleted"   
)

◆ STATISTIC() [3/6]

STATISTIC ( NumOpenMPRuntimeFunctionsIdentified  ,
"Number of OpenMP runtime functions identified"   
)

◆ STATISTIC() [4/6]

STATISTIC ( NumOpenMPRuntimeFunctionUsesIdentified  ,
"Number of OpenMP runtime function uses identified"   
)

◆ STATISTIC() [5/6]

STATISTIC ( NumOpenMPTargetRegionKernels  ,
"Number of OpenMP target region entry points (=kernels) identified"   
)

◆ STATISTIC() [6/6]

STATISTIC ( NumOpenMPParallelRegionsReplacedInGPUStateMachine  ,
"Number of OpenMP parallel regions replaced with ID in GPU state machines"   
)

Variable Documentation

◆ DisableOpenMPOptimizations

cl::opt<bool> DisableOpenMPOptimizations("openmp-opt-disable", cl::ZeroOrMore, cl::desc("Disable OpenMP specific optimizations."), cl::Hidden, cl::init(false))
static

◆ false

OpenMP specific false

Definition at line 1498 of file OpenMPOpt.cpp.

◆ openmpopt

openmpopt

Definition at line 1498 of file OpenMPOpt.cpp.

◆ optimizations

OpenMP specific optimizations

Definition at line 1498 of file OpenMPOpt.cpp.

◆ PrintICVValues

cl::opt<bool> PrintICVValues("openmp-print-icv-values", cl::init(false), cl::Hidden)
static

◆ PrintOpenMPKernels

cl::opt<bool> PrintOpenMPKernels("openmp-print-gpu-kernels", cl::init(false), cl::Hidden)
static

◆ TAG

constexpr auto TAG = "[" DEBUG_TYPE "]"
static

Definition at line 60 of file OpenMPOpt.cpp.