LLVM  13.0.0git
Macros | Functions | Variables
OpenMPOpt.cpp File Reference
#include "llvm/Transforms/IPO/OpenMPOpt.h"
#include "llvm/ADT/EnumeratedArray.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ValueTracking.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/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
Include dependency graph for OpenMPOpt.cpp:

Go to the source code of this file.

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")
 
 STATISTIC (NumOpenMPParallelRegionsMerged, "Number of OpenMP parallel regions merged")
 
 INITIALIZE_PASS_BEGIN (OpenMPOptCGSCCLegacyPass, "openmp-opt-cgscc", "OpenMP specific optimizations", false, false) INITIALIZE_PASS_END(OpenMPOptCGSCCLegacyPass
 

Variables

static cl::opt< bool > DisableOpenMPOptimizations ("openmp-opt-disable", cl::ZeroOrMore, cl::desc("Disable OpenMP specific optimizations."), cl::Hidden, cl::init(false))
 
static cl::opt< bool > EnableParallelRegionMerging ("openmp-opt-enable-merging", cl::ZeroOrMore, cl::desc("Enable the OpenMP region merging optimization."), cl::Hidden, cl::init(false))
 
static cl::opt< bool > PrintICVValues ("openmp-print-icv-values", cl::init(false), cl::Hidden)
 
static cl::opt< bool > PrintOpenMPKernels ("openmp-print-gpu-kernels", cl::init(false), cl::Hidden)
 
static cl::opt< bool > HideMemoryTransferLatency ("openmp-hide-memory-transfer-latency", cl::desc("[WIP] Tries to hide the latency of host to device memory" " transfers"), cl::Hidden, cl::init(false))
 
static constexpr auto TAG = "[" DEBUG_TYPE "]"
 
openmp opt cgscc
 
openmp opt OpenMP specific optimizations
 
openmp opt OpenMP specific false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "openmp-opt"

Definition at line 37 of file OpenMPOpt.cpp.

◆ 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; \
} \
}

◆ ICV_RT_GET

#define ICV_RT_GET (   Name,
  RTL 
)
Value:
{ \
auto &ICV = ICVs[Name]; \
ICV.Getter = RTL; \
}

◆ 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;

◆ OMP_FUNCTION_TYPE

#define OMP_FUNCTION_TYPE (   VarName,
  ... 
)
Value:
FunctionType *VarName = OMPBuilder.VarName; \
(void)VarName; \
PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr; \
(void)VarName##Ptr;

◆ 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"; \
}); \
} \
}

◆ OMP_RTL [2/2]

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

◆ OMP_STRUCT_TYPE

#define OMP_STRUCT_TYPE (   VarName,
  ... 
)
Value:
StructType *VarName = OMPBuilder.VarName; \
(void)VarName; \
PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr; \
(void)VarName##Ptr;

◆ OMP_TYPE

#define OMP_TYPE (   VarName,
  ... 
)
Value:
Type *VarName = OMPBuilder.VarName; \
(void)VarName;

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( OpenMPOptCGSCCLegacyPass  ,
"openmp-opt-cgscc ,
"OpenMP specific optimizations ,
false  ,
false   
)

◆ STATISTIC() [1/7]

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

◆ STATISTIC() [2/7]

STATISTIC ( NumOpenMPParallelRegionsMerged  ,
"Number of OpenMP parallel regions merged"   
)

◆ STATISTIC() [3/7]

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

◆ STATISTIC() [4/7]

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

◆ STATISTIC() [5/7]

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

◆ STATISTIC() [6/7]

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

◆ STATISTIC() [7/7]

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

Variable Documentation

◆ cgscc

openmp opt cgscc

Definition at line 2697 of file OpenMPOpt.cpp.

◆ DisableOpenMPOptimizations

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

◆ EnableParallelRegionMerging

cl::opt<bool> EnableParallelRegionMerging("openmp-opt-enable-merging", cl::ZeroOrMore, cl::desc("Enable the OpenMP region merging optimization."), cl::Hidden, cl::init(false))
static

◆ false

openmp opt OpenMP specific false

Definition at line 2698 of file OpenMPOpt.cpp.

◆ HideMemoryTransferLatency

cl::opt<bool> HideMemoryTransferLatency("openmp-hide-memory-transfer-latency", cl::desc("[WIP] Tries to hide the latency of host to device memory" " transfers"), cl::Hidden, cl::init(false))
static

◆ optimizations

openmp opt OpenMP specific optimizations

Definition at line 2698 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 "]"
staticconstexpr

Definition at line 77 of file OpenMPOpt.cpp.

M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Function
Definition: Function.h:61
TAG
static constexpr auto TAG
Definition: OpenMPOpt.cpp:77
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:71
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:359
F
#define F(x, y, z)
Definition: MD5.cpp:56
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
getFalse
static Constant * getFalse(Type *Ty)
For a boolean type or a vector of boolean type, return false or a vector with every element false.
Definition: InstructionSimplify.cpp:119
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:212
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::Init
Definition: Record.h:271
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:102