LLVM 20.0.0git
|
This file implements the OpenMPIRBuilder class, which is used as a convenient way to create LLVM instructions for OpenMP directives. More...
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Frontend/Offloading/Utility.h"
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ReplaceConstant.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
#include "llvm/Transforms/Utils/LoopPeel.h"
#include "llvm/Transforms/Utils/UnrollLoop.h"
#include <cstdint>
#include <optional>
#include "llvm/Frontend/OpenMP/OMPKinds.def"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "openmp-ir-builder" |
#define | OMP_ATTRS_SET(VarName, AttrSet) AttributeSet VarName = AttrSet; |
#define | OMP_RTL_ATTRS(Enum, FnAttrSet, RetAttrSet, ArgAttrSets) |
#define | OMP_RTL(Enum, Str, IsVarArg, ReturnType, ...) |
#define | OMP_RTL(Enum, Str, ...) |
#define | OMP_CANCEL_KIND(Enum, Str, DirectiveEnum, Value) |
#define | OMP_TYPE(VarName, InitValue) VarName = InitValue; |
#define | OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) |
#define | OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) |
#define | OMP_STRUCT_TYPE(VarName, StructName, Packed, ...) |
Functions | |
static bool | isConflictIP (IRBuilder<>::InsertPoint IP1, IRBuilder<>::InsertPoint IP2) |
Return whether IP1 and IP2 are ambiguous, i.e. | |
static bool | isValidWorkshareLoopScheduleType (OMPScheduleType SchedType) |
static const omp::GV & | getGridValue (const Triple &T, Function *Kernel) |
static OMPScheduleType | getOpenMPBaseScheduleType (llvm::omp::ScheduleKind ClauseKind, bool HasChunks, bool HasSimdModifier) |
Determine which scheduling algorithm to use, determined from schedule clause arguments. | |
static OMPScheduleType | getOpenMPOrderingScheduleType (OMPScheduleType BaseScheduleType, bool HasOrderedClause) |
Adds ordering modifier flags to schedule type. | |
static OMPScheduleType | getOpenMPMonotonicityScheduleType (OMPScheduleType ScheduleType, bool HasSimdModifier, bool HasMonotonic, bool HasNonmonotonic, bool HasOrderedClause) |
Adds monotonicity modifier flags to schedule type. | |
static OMPScheduleType | computeOpenMPScheduleType (ScheduleKind ClauseKind, bool HasChunks, bool HasSimdModifier, bool HasMonotonicModifier, bool HasNonmonotonicModifier, bool HasOrderedClause) |
Determine the schedule type using schedule and ordering clause arguments. | |
static void | redirectTo (BasicBlock *Source, BasicBlock *Target, DebugLoc DL) |
Make Source branch to Target . | |
Value * | createFakeIntVal (IRBuilderBase &Builder, OpenMPIRBuilder::InsertPointTy OuterAllocaIP, llvm::SmallVectorImpl< Instruction * > &ToBeDeleted, OpenMPIRBuilder::InsertPointTy InnerAllocaIP, const Twine &Name="", bool AsPtr=true) |
static void | raiseUserConstantDataAllocasToEntryBlock (IRBuilderBase &Builder, Function *Function) |
static void | targetParallelCallback (OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn, Function *OuterFn, BasicBlock *OuterAllocaBB, Value *Ident, Value *IfCondition, Value *NumThreads, Instruction *PrivTID, AllocaInst *PrivTIDAddr, Value *ThreadID, const SmallVector< Instruction *, 4 > &ToBeDeleted) |
static void | hostParallelCallback (OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn, Function *OuterFn, Value *Ident, Value *IfCondition, Instruction *PrivTID, AllocaInst *PrivTIDAddr, const SmallVector< Instruction *, 4 > &ToBeDeleted) |
static Value * | emitTaskDependencies (OpenMPIRBuilder &OMPBuilder, const SmallVectorImpl< OpenMPIRBuilder::DependData > &Dependencies) |
static OpenMPIRBuilder::InsertPointTy | getInsertPointAfterInstr (Instruction *I) |
static void | checkReductionInfos (ArrayRef< OpenMPIRBuilder::ReductionInfo > ReductionInfos, bool IsGPU) |
static Function * | getFreshReductionFunc (Module &M) |
static FunctionCallee | getKmpcForStaticInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
static FunctionCallee | getKmpcForStaticLoopForType (Type *Ty, OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType) |
static void | createTargetLoopWorkshareCall (OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType, BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg, Type *ParallelTaskPtr, Value *TripCount, Function &LoopBodyFn) |
static void | workshareLoopTargetCallback (OpenMPIRBuilder *OMPIRBuilder, CanonicalLoopInfo *CLI, Value *Ident, Function &OutlinedFn, Type *ParallelTaskPtr, const SmallVector< Instruction *, 4 > &ToBeDeleted, WorksharingLoopType LoopType) |
static FunctionCallee | getKmpcForDynamicInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
Returns an LLVM function to call for initializing loop bounds using OpenMP dynamic scheduling depending on type . | |
static FunctionCallee | getKmpcForDynamicNextForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
Returns an LLVM function to call for updating the next loop using OpenMP dynamic scheduling depending on type . | |
static FunctionCallee | getKmpcForDynamicFiniForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
Returns an LLVM function to call for finalizing the dynamic loop using depending on type . | |
static void | redirectAllPredecessorsTo (BasicBlock *OldTarget, BasicBlock *NewTarget, DebugLoc DL) |
Redirect all edges that branch to OldTarget to NewTarget . | |
static void | removeUnusedBlocksFromParent (ArrayRef< BasicBlock * > BBs) |
Determine which blocks in BBs are reachable from outside and remove the ones that are not reachable from the function. | |
static void | addBasicBlockMetadata (BasicBlock *BB, ArrayRef< Metadata * > Properties) |
Attach metadata Properties to the basic block described by BB . | |
static void | addLoopMetadata (CanonicalLoopInfo *Loop, ArrayRef< Metadata * > Properties) |
Attach loop metadata Properties to the loop described by Loop . | |
static void | addSimdMetadata (BasicBlock *Block, MDNode *AccessGroup, LoopInfo &LI) |
Attach llvm.access.group metadata to the memref instructions of Block . | |
static std::unique_ptr< TargetMachine > | createTargetMachine (Function *F, CodeGenOptLevel OptLevel) |
Create the TargetMachine object to query the backend for optimization preferences. | |
static int32_t | computeHeuristicUnrollFactor (CanonicalLoopInfo *CLI) |
Heuristically determine the best-performant unroll factor for CLI . | |
static MDNode * | getNVPTXMDNode (Function &Kernel, StringRef Name) |
static void | updateNVPTXMetadata (Function &Kernel, StringRef Name, int32_t Value, bool Min) |
static Expected< Function * > | createOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, StringRef FuncName, SmallVectorImpl< Value * > &Inputs, OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc, OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy &ArgAccessorFuncCB) |
static Function * | emitTargetTaskProxyFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, CallInst *StaleCI) |
Create an entry point for a target task with the following. | |
static Error | emitTargetOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, bool IsOffloadEntry, TargetRegionEntryInfo &EntryInfo, Function *&OutlinedFn, Constant *&OutlinedFnID, SmallVectorImpl< Value * > &Inputs, OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc, OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy &ArgAccessorFuncCB) |
static void | emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, OpenMPIRBuilder::InsertPointTy AllocaIP, Function *OutlinedFn, Constant *OutlinedFnID, ArrayRef< int32_t > NumTeams, ArrayRef< int32_t > NumThreads, SmallVectorImpl< Value * > &Args, OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB, SmallVector< llvm::OpenMPIRBuilder::DependData > Dependencies={}, bool HasNoWait=false) |
Variables | |
static cl::opt< bool > | OptimisticAttributes ("openmp-ir-builder-optimistic-attributes", cl::Hidden, cl::desc("Use optimistic attributes describing " "'as-if' properties of runtime calls."), cl::init(false)) |
static cl::opt< double > | UnrollThresholdFactor ("openmp-ir-builder-unroll-threshold-factor", cl::Hidden, cl::desc("Factor for the unroll threshold to account for code " "simplifications still taking place"), cl::init(1.5)) |
This file implements the OpenMPIRBuilder class, which is used as a convenient way to create LLVM instructions for OpenMP directives.
Definition in file OMPIRBuilder.cpp.
#define DEBUG_TYPE "openmp-ir-builder" |
Definition at line 63 of file OMPIRBuilder.cpp.
#define OMP_ARRAY_TYPE | ( | VarName, | |
ElemTy, | |||
ArraySize | |||
) |
#define OMP_ATTRS_SET | ( | VarName, | |
AttrSet | |||
) | AttributeSet VarName = AttrSet; |
#define OMP_CANCEL_KIND | ( | Enum, | |
Str, | |||
DirectiveEnum, | |||
Value | |||
) |
#define OMP_FUNCTION_TYPE | ( | VarName, | |
IsVarArg, | |||
ReturnType, | |||
... | |||
) |
#define OMP_RTL | ( | Enum, | |
Str, | |||
IsVarArg, | |||
ReturnType, | |||
... | |||
) |
#define OMP_RTL | ( | Enum, | |
Str, | |||
... | |||
) |
#define OMP_RTL_ATTRS | ( | Enum, | |
FnAttrSet, | |||
RetAttrSet, | |||
ArgAttrSets | |||
) |
#define OMP_STRUCT_TYPE | ( | VarName, | |
StructName, | |||
Packed, | |||
... | |||
) |
#define OMP_TYPE | ( | VarName, | |
InitValue | |||
) | VarName = InitValue; |
|
static |
Attach metadata Properties
to the basic block described by BB
.
If the basic block already has metadata, the basic block properties are appended.
Definition at line 5142 of file OMPIRBuilder.cpp.
References llvm::append_range(), llvm::drop_begin(), llvm::ArrayRef< T >::empty(), llvm::BasicBlock::getContext(), llvm::MDNode::getDistinct(), llvm::Instruction::getMetadata(), llvm::BasicBlock::getTerminator(), llvm::MDNode::operands(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MDNode::replaceOperandWith(), and llvm::Instruction::setMetadata().
Referenced by addLoopMetadata(), and llvm::OpenMPIRBuilder::applySimd().
|
static |
Attach loop metadata Properties
to the loop described by Loop
.
If the loop already has metadata, the loop properties are appended.
Definition at line 5166 of file OMPIRBuilder.cpp.
References addBasicBlockMetadata(), and assert().
Referenced by llvm::OpenMPIRBuilder::applySimd(), llvm::OpenMPIRBuilder::unrollLoopFull(), llvm::OpenMPIRBuilder::unrollLoopHeuristic(), and llvm::OpenMPIRBuilder::unrollLoopPartial().
|
static |
Attach llvm.access.group metadata to the memref instructions of Block
.
Definition at line 5177 of file OMPIRBuilder.cpp.
References llvm::Block, and I.
Referenced by llvm::OpenMPIRBuilder::applySimd().
|
static |
Definition at line 3446 of file OMPIRBuilder.cpp.
References assert().
Referenced by llvm::OpenMPIRBuilder::createReductionsGPU().
|
static |
Heuristically determine the best-performant unroll factor for CLI
.
This depends on the target processor. We are re-using the same heuristics as the LoopUnrollPass.
Definition at line 5423 of file OMPIRBuilder.cpp.
References llvm::Aggressive, assert(), llvm::TargetTransformInfo::UnrollingPreferences::BEInsns, llvm::UnrollCostEstimator::canUnroll(), llvm::CodeMetrics::collectEphemeralValues(), llvm::computeUnrollCount(), llvm::TargetTransformInfo::UnrollingPreferences::Count, createTargetMachine(), llvm::dbgs(), F, FAM, llvm::TargetTransformInfo::UnrollingPreferences::Force, llvm::gatherPeelingPreferences(), llvm::gatherUnrollingPreferences(), llvm::CanonicalLoopInfo::getFunction(), llvm::CanonicalLoopInfo::getHeader(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::UnrollCostEstimator::getRolledLoopSize(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, llvm::TargetTransformInfo::UnrollingPreferences::OptSizeThreshold, llvm::TargetTransformInfo::UnrollingPreferences::PartialOptSizeThreshold, llvm::TargetTransformInfo::UnrollingPreferences::PartialThreshold, Ptr, llvm::AnalysisManager< IRUnitT, ExtraArgTs >::registerPass(), llvm::TargetIRAnalysis::run(), llvm::AssumptionAnalysis::run(), llvm::DominatorTreeAnalysis::run(), llvm::LoopAnalysis::run(), llvm::ScalarEvolutionAnalysis::run(), llvm::TargetTransformInfo::UnrollingPreferences::Threshold, and UnrollThresholdFactor.
Referenced by llvm::OpenMPIRBuilder::unrollLoopPartial().
|
static |
Determine the schedule type using schedule and ordering clause arguments.
Definition at line 252 of file OMPIRBuilder.cpp.
References assert(), getOpenMPBaseScheduleType(), getOpenMPMonotonicityScheduleType(), getOpenMPOrderingScheduleType(), and isValidWorkshareLoopScheduleType().
Referenced by llvm::OpenMPIRBuilder::applyWorkshareLoop().
Value * createFakeIntVal | ( | IRBuilderBase & | Builder, |
OpenMPIRBuilder::InsertPointTy | OuterAllocaIP, | ||
llvm::SmallVectorImpl< Instruction * > & | ToBeDeleted, | ||
OpenMPIRBuilder::InsertPointTy | InnerAllocaIP, | ||
const Twine & | Name = "" , |
||
bool | AsPtr = true |
||
) |
Definition at line 364 of file OMPIRBuilder.cpp.
References llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt32Ty(), Name, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::IRBuilderBase::restoreIP().
Referenced by llvm::OpenMPIRBuilder::createTask(), llvm::OpenMPIRBuilder::createTeams(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 6744 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::begin(), llvm::OpenMPIRBuilder::Config, llvm::OpenMPIRBuilder::ConstantAllocaRaiseCandidates, llvm::convertUsersOfConstantsToInstructions(), llvm::Function::Create(), llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateRetVoid(), llvm::OpenMPIRBuilder::createTargetDeinit(), llvm::OpenMPIRBuilder::createTargetInit(), DL, llvm::SmallVectorImpl< T >::emplace_back(), llvm::MDNode::get(), llvm::FunctionType::get(), llvm::IRBuilderBase::getContext(), llvm::IRBuilderBase::getCurrentDebugLocation(), llvm::BasicBlock::getFirstNonPHI(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::IRBuilderBase::GetInsertBlock(), llvm::Type::getInt64Ty(), llvm::GlobalValue::getParent(), llvm::DILocalScope::getSubprogram(), llvm::PointerType::getUnqual(), llvm::IRBuilderBase::getVoidTy(), llvm::GlobalValue::InternalLinkage, llvm::OpenMPIRBuilderConfig::isTargetDevice(), llvm::make_early_inc_range(), llvm::make_range(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::IRBuilderBase::restoreIP(), llvm::IRBuilderBase::saveIP(), llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::IRBuilderBase::SetInsertPoint(), llvm::splitBB(), llvm::Expected< T >::takeError(), llvm::Value::users(), and llvm::zip().
Referenced by emitTargetOutlinedFunction().
|
static |
Definition at line 4368 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Builder, llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateZExtOrTrunc(), llvm::BasicBlock::end(), getKmpcForStaticLoopForType(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm::Value::getType(), llvm::OpenMPIRBuilder::M, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::IRBuilderBase::restoreIP().
Referenced by workshareLoopTargetCallback().
|
static |
Create the TargetMachine object to query the backend for optimization preferences.
Ideally, this would be passed from the front-end to the OpenMPBuilder, but e.g. Clang does not pass it to its CodeGen layer and creates it only when needed for the LLVM pass pipline. We use some default options to avoid having to pass too many settings from the frontend that probably do not matter.
Currently, TargetMachine is only used sometimes by the unrollLoopPartial method. If we are going to use TargetMachine for more purposes, especially those that are sensitive to TargetOptions, RelocModel and CodeModel, it might become be worth requiring front-ends to pass on their TargetMachine, or at least cache it between methods. Note that while fontends such as Clang have just a single main TargetMachine per translation unit, "target-cpu" and "target-features" that determine the TargetMachine are per-function and can be overrided using attribute((target("OPTIONS"))).
Definition at line 5402 of file OMPIRBuilder.cpp.
References llvm::Target::createTargetMachine(), F, llvm::TargetRegistry::lookupTarget(), and Options.
Referenced by llvm::lto::backend(), computeHeuristicUnrollFactor(), LLVMCreateTargetMachineWithOptions(), splitCodeGen(), and llvm::lto::thinBackend().
|
static |
Definition at line 7316 of file OMPIRBuilder.cpp.
Referenced by llvm::OpenMPIRBuilder::createTarget().
|
static |
Definition at line 7010 of file OMPIRBuilder.cpp.
References createOutlinedFunction(), and llvm::OpenMPIRBuilder::emitTargetRegionFunction().
Referenced by llvm::OpenMPIRBuilder::createTarget().
|
static |
Create an entry point for a target task with the following.
It'll have the following signature void .omp_target_task_proxy_func(i32 thread.id, ptr task) This function is called from emitTargetTask once the code to launch the target kernel has been outlined already.
Definition at line 6930 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::Function::Create(), llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateMemCpy(), llvm::IRBuilderBase::CreateRetVoid(), llvm::IRBuilderBase::CreateStructGEP(), llvm::FunctionType::get(), llvm::AllocaInst::getAlign(), llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledFunction(), llvm::IRBuilderBase::getContext(), llvm::IRBuilderBase::GetInsertBlock(), llvm::Type::getInt32Ty(), llvm::IRBuilderBase::getInt64(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::BasicBlock::getModule(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getPointerAlignment(), llvm::PointerType::getUnqual(), llvm::IRBuilderBase::getVoidTy(), llvm::GlobalValue::InternalLinkage, llvm::OpenMPIRBuilder::M, and llvm::IRBuilderBase::SetInsertPoint().
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 1755 of file OMPIRBuilder.cpp.
References Addr, llvm::sampleprof::Base, llvm::OpenMPIRBuilder::Builder, llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateConstInBoundsGEP2_64(), llvm::IRBuilderBase::CreatePtrToInt(), llvm::IRBuilderBase::CreateStore(), llvm::IRBuilderBase::CreateStructGEP(), llvm::SmallVectorBase< Size_T >::empty(), llvm::enumerate(), llvm::omp::Flags, llvm::ArrayType::get(), llvm::IRBuilderBase::InsertPoint::getBlock(), llvm::Function::getEntryBlock(), llvm::IRBuilderBase::getInt64(), llvm::IRBuilderBase::getInt64Ty(), llvm::IRBuilderBase::getInt8Ty(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::OpenMPIRBuilder::M, llvm::IRBuilderBase::restoreIP(), llvm::IRBuilderBase::saveIP(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorBase< Size_T >::size(), and Size.
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
Definition at line 3652 of file OMPIRBuilder.cpp.
References llvm::Function::Create(), llvm::FunctionType::get(), llvm::PointerType::getUnqual(), llvm::Type::getVoidTy(), and llvm::GlobalValue::InternalLinkage.
Referenced by llvm::OpenMPIRBuilder::createReductions().
Definition at line 152 of file OMPIRBuilder.cpp.
References llvm::StringRef::count(), llvm::Function::getFnAttribute(), llvm::Attribute::getValueAsString(), llvm_unreachable, and llvm::omp::NVPTXGridValues.
Referenced by llvm::OpenMPIRBuilder::createReductionsGPU(), and llvm::OpenMPIRBuilder::createTargetInit().
|
static |
Definition at line 2257 of file OMPIRBuilder.cpp.
|
static |
Returns an LLVM function to call for finalizing the dynamic loop using depending on type
.
Only i32 and i64 are supported by the runtime. Always interpret integers as unsigned similarly to CanonicalLoopInfo.
Definition at line 4646 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Returns an LLVM function to call for initializing loop bounds using OpenMP dynamic scheduling depending on type
.
Only i32 and i64 are supported by the runtime. Always interpret integers as unsigned similarly to CanonicalLoopInfo.
Definition at line 4615 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Returns an LLVM function to call for updating the next loop using OpenMP dynamic scheduling depending on type
.
Only i32 and i64 are supported by the runtime. Always interpret integers as unsigned similarly to CanonicalLoopInfo.
Definition at line 4631 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 4061 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 4330 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm_unreachable, and llvm::OpenMPIRBuilder::M.
Referenced by createTargetLoopWorkshareCall().
Definition at line 6298 of file OMPIRBuilder.cpp.
References llvm::DWARFExpression::Operation::getNumOperands(), llvm::GlobalValue::getParent(), Name, and llvm::NamedMDNode::operands().
Referenced by llvm::OpenMPIRBuilder::readThreadBoundsForKernel(), and updateNVPTXMetadata().
|
static |
Determine which scheduling algorithm to use, determined from schedule clause arguments.
Definition at line 168 of file OMPIRBuilder.cpp.
References llvm::omp::BaseAuto, and llvm_unreachable.
Referenced by computeOpenMPScheduleType().
|
static |
Adds monotonicity modifier flags to schedule type.
Definition at line 216 of file OMPIRBuilder.cpp.
References assert(), and llvm::omp::ModifierMask.
Referenced by computeOpenMPScheduleType().
|
static |
Adds ordering modifier flags to schedule type.
Definition at line 192 of file OMPIRBuilder.cpp.
References assert().
Referenced by computeOpenMPScheduleType().
|
static |
Definition at line 1285 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), llvm::Function::addParamAttr(), llvm::SmallVectorImpl< T >::append(), llvm::Function::arg_begin(), llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), llvm::Function::arg_size(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::OpenMPIRBuilder::Builder, Cond, llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateCall(), llvm::MDBuilder::createCallbackEncoding(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateSExtOrTrunc(), llvm::IRBuilderBase::CreateStore(), llvm::dbgs(), llvm::Instruction::eraseFromParent(), F, llvm::MDNode::get(), llvm::FunctionCallee::getCallee(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32(), llvm::Constant::getNullValue(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getParent(), I, LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::Value::user_back().
Referenced by llvm::OpenMPIRBuilder::createParallel().
Return whether IP1 and IP2 are ambiguous, i.e.
that inserting instructions at position IP1 may change the meaning of IP2 or vice-versa. This is because an InsertPoint stores the instruction before something is inserted. For instance, if both point to the same instruction, two IRBuilders alternating creating instruction will cause the instructions to be interleaved.
Definition at line 86 of file OMPIRBuilder.cpp.
Referenced by llvm::OpenMPIRBuilder::createAtomicUpdate(), llvm::OpenMPIRBuilder::createParallel(), and llvm::OpenMPIRBuilder::createSections().
|
static |
Definition at line 93 of file OMPIRBuilder.cpp.
Referenced by computeOpenMPScheduleType().
|
static |
Definition at line 651 of file OMPIRBuilder.cpp.
References llvm::Function::begin(), llvm::Block, llvm::Function::end(), llvm::AllocaInst::getArraySize(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHI(), and llvm::Instruction::moveBeforePreserving().
Referenced by llvm::OpenMPIRBuilder::finalize().
|
static |
Redirect all edges that branch to OldTarget
to NewTarget
.
That is, after this OldTarget
will be orphaned.
Definition at line 4791 of file OMPIRBuilder.cpp.
References DL, llvm::make_early_inc_range(), llvm::predecessors(), and redirectTo().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), and llvm::OpenMPIRBuilder::tileLoops().
|
static |
Make Source
branch to Target
.
Handles two situations:
Source
already has an unconditional branch.Source
is a degenerate block (no terminator because the BB is the current head of the IR construction). Definition at line 273 of file OMPIRBuilder.cpp.
References assert(), llvm::BranchInst::Create(), DL, and llvm::BasicBlock::removePredecessor().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), redirectAllPredecessorsTo(), and llvm::OpenMPIRBuilder::tileLoops().
|
static |
Determine which blocks in BBs
are reachable from outside and remove the ones that are not reachable from the function.
Definition at line 4799 of file OMPIRBuilder.cpp.
References llvm::ArrayRef< T >::begin(), llvm::DeleteDeadBlocks(), and llvm::ArrayRef< T >::end().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), and llvm::OpenMPIRBuilder::tileLoops().
|
static |
Definition at line 1196 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), llvm::Function::addParamAttr(), llvm::Function::arg_begin(), llvm::CallBase::arg_begin(), llvm::Function::arg_size(), assert(), llvm::OpenMPIRBuilder::Builder, Cond, llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateConstInBoundsGEP2_64(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreatePointerCast(), llvm::IRBuilderBase::CreateSExtOrTrunc(), llvm::IRBuilderBase::CreateStore(), llvm::dbgs(), llvm::Instruction::eraseFromParent(), llvm::ArrayType::get(), llvm::AllocaInst::getAddressSpace(), llvm::BasicBlock::getFirstInsertionPt(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt64(), llvm::Constant::getNullValue(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getParent(), I, Idx, LLVM_DEBUG, llvm::IRBuilderBase::restoreIP(), llvm::IRBuilderBase::saveIP(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::Value::user_back().
Referenced by llvm::OpenMPIRBuilder::createParallel().
|
static |
Definition at line 6315 of file OMPIRBuilder.cpp.
References llvm::NamedMDNode::addOperand(), llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::MDString::get(), llvm::Function::getContext(), llvm::Type::getInt32Ty(), getNVPTXMDNode(), llvm::MDNode::getOperand(), llvm::GlobalValue::getParent(), Name, and llvm::MDNode::replaceOperandWith().
Referenced by llvm::OpenMPIRBuilder::writeTeamsForKernel(), and llvm::OpenMPIRBuilder::writeThreadBoundsForKernel().
|
static |
Definition at line 4403 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::BasicBlock::begin(), llvm::OpenMPIRBuilder::Builder, llvm::OpenMPIRBuilder::OutlineInfo::collectBlocks(), llvm::IRBuilderBase::CreateBr(), createTargetLoopWorkshareCall(), llvm::DeleteDeadBlocks(), llvm::BasicBlock::end(), llvm::OpenMPIRBuilder::OutlineInfo::EntryBB, llvm::Instruction::eraseFromParent(), llvm::OpenMPIRBuilder::OutlineInfo::ExitBB, llvm::CallBase::getArgOperand(), llvm::CanonicalLoopInfo::getBody(), llvm::Instruction::getDebugLoc(), llvm::CanonicalLoopInfo::getExit(), llvm::CanonicalLoopInfo::getHeader(), llvm::Constant::getNullValue(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::CanonicalLoopInfo::getPreheader(), llvm::IRBuilderBase::getPtrTy(), llvm::BasicBlock::getTerminator(), llvm::CanonicalLoopInfo::getTripCount(), llvm::Value::getUniqueUndroppableUser(), llvm::CanonicalLoopInfo::invalidate(), llvm::IRBuilderBase::restoreIP(), llvm::IRBuilderBase::SetCurrentDebugLocation(), and llvm::BasicBlock::splice().
|
static |
|
static |
Referenced by computeHeuristicUnrollFactor().