|
LLVM 24.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/SmallVectorExtras.h"#include "llvm/ADT/StringExtras.h"#include "llvm/ADT/StringRef.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/PostDominators.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/InstIterator.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/Support/CommandLine.h"#include "llvm/Support/Error.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/NVVMAttributes.h"#include "llvm/Support/VirtualFileSystem.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/CodeExtractor.h"#include <cstdint>#include <optional>#include "llvm/Frontend/OpenMP/OMPKinds.def"Go to the source code of this file.
Classes | |
| struct | llvm::OpenMPIRBuilder::VirtualRowPlan |
| Physical handles captured before the source descriptors are invalidated. More... | |
Macros | |
| #define | DEBUG_TYPE "openmp-ir-builder" |
| #define | OMP_ATTRS_SET(VarName, AttrSet) |
| #define | OMP_RTL_ATTRS(Enum, FnAttrSet, RetAttrSet, ArgAttrSets) |
| #define | OMP_RTL(Enum, Str, IsVarArg, ReturnType, ...) |
| #define | OMP_CANCEL_KIND(Enum, Str, DirectiveEnum, Value) |
| #define | OMP_CANCEL_KIND(Enum, Str, DirectiveEnum, Value) |
| #define | OMP_TYPE(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 void | restoreIPandDebugLoc (llvm::IRBuilderBase &Builder, llvm::IRBuilderBase::InsertPoint IP) |
| This is a wrapper over IRBuilderBase::restoreIP that also restores a current debug location when the insert point is at the end of a block. | |
| static bool | hasGridValue (const Triple &T) |
| static const omp::GV & | getGridValue (const Triple &T, Function *Kernel) |
| static OMPScheduleType | getOpenMPBaseScheduleType (llvm::omp::ScheduleKind ClauseKind, bool HasChunks, bool HasSimdModifier, bool HasDistScheduleChunks) |
| 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, bool HasDistScheduleChunks) |
| Determine the schedule type using schedule and ordering clause arguments. | |
| static std::optional< omp::OMPTgtExecModeFlags > | getTargetKernelExecMode (Function &Kernel) |
| Given a function, if it represents the entry point of a target kernel, this returns the execution mode flags associated with that kernel. | |
| static bool | isGenericKernel (Function &Fn) |
| 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, bool Is64Bit=false) |
| static void | raiseUserConstantDataAllocasToEntryBlock (IRBuilderBase &Builder, Function *Function) |
| static void | hoistNonEntryAllocasToEntryBlock (llvm::BasicBlock &Block) |
| static void | hoistNonEntryAllocasToEntryBlock (llvm::Function *Func) |
| static Function * | createTargetParallelWrapper (OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn) |
| Create wrapper function used to gather the outlined function's argument structure from a shared buffer and to forward them to it when running in Generic mode. | |
| 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 bool | isAtomicableReductionSet (ArrayRef< OpenMPIRBuilder::ReductionInfo > ReductionInfos) |
| static Function * | getFreshReductionFunc (Module &M) |
| static Error | populateReductionFunction (Function *ReductionFunc, ArrayRef< OpenMPIRBuilder::ReductionInfo > ReductionInfos, IRBuilder<> &Builder, ArrayRef< bool > IsByRef, bool IsGPU) |
| static llvm::CallInst * | emitNoUnwindRuntimeCall (IRBuilder<> &Builder, llvm::FunctionCallee Callee, ArrayRef< llvm::Value * > Args, const llvm::Twine &Name) |
| static FunctionCallee | getKmpcDistForStaticInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
| static FunctionCallee | getKmpcForStaticInitForType (Type *Ty, Module &M, OpenMPIRBuilder &OMPBuilder) |
| static void | addAccessGroupMetadata (BasicBlock *Block, MDNode *AccessGroup, LoopInfo &LI) |
Attach llvm.access.group metadata to the memref instructions of Block. | |
| static void | addLoopMetadata (CanonicalLoopInfo *Loop, ArrayRef< Metadata * > Properties) |
Attach loop metadata Properties to the loop described by Loop. | |
| static void | applyParallelAccessesMetadata (CanonicalLoopInfo *CLI, LLVMContext &Ctx, Loop *Loop, LoopInfo &LoopInfo, SmallVector< Metadata * > &LoopMDList) |
| static FunctionCallee | getKmpcForStaticLoopForType (Type *Ty, OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType) |
| static void | createTargetLoopWorkshareCall (OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType, BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg, Value *TripCount, Function &LoopBodyFn, bool NoLoop) |
| static void | workshareLoopTargetCallback (OpenMPIRBuilder *OMPIRBuilder, CanonicalLoopInfo *CLI, Value *Ident, Function &OutlinedFn, const SmallVector< Instruction *, 4 > &ToBeDeleted, WorksharingLoopType LoopType, bool NoLoop) |
| 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) |
| static void | addBasicBlockMetadata (BasicBlock *BB, ArrayRef< Metadata * > Properties) |
Attach metadata Properties to the basic block described by BB. | |
| static void | updateNVPTXAttr (Function &Kernel, StringRef Name, int32_t Value, bool Min) |
| static void | FixupDebugInfoForOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, Function *Func, DenseMap< Value *, std::tuple< Value *, unsigned > > &ValueReplacementMap) |
| static Value * | removeASCastIfPresent (Value *V) |
| static Expected< Function * > | createOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs, StringRef FuncName, SmallVectorImpl< Value * > &Inputs, OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc, OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy &ArgAccessorFuncCB, DebugLoc OutlinedFnLoc) |
| static LoadInst * | loadSharedDataFromTaskDescriptor (IRBuilderBase &Builder, Value *TaskWithPrivates) |
| Given a task descriptor, TaskWithPrivates, return the pointer to the block of pointers containing shared data between the parent task and the created task. | |
| static Function * | emitTargetTaskProxyFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, CallInst *StaleCI, StructType *PrivatesTy, StructType *TaskWithPrivatesTy, const size_t NumOffloadingArrays, const int SharedArgsOperandNo) |
| Create an entry point for a target task with the following. | |
| static Type * | getOffloadingArrayType (Value *V) |
| static StructType * | createTaskWithPrivatesTy (OpenMPIRBuilder &OMPIRBuilder, ArrayRef< Value * > OffloadingArraysToPrivatize, ArrayRef< Type * > DescriptorTypes) |
| static Error | emitTargetOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, bool IsOffloadEntry, TargetRegionEntryInfo &EntryInfo, const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs, Function *&OutlinedFn, Constant *&OutlinedFnID, SmallVectorImpl< Value * > &Inputs, OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc, OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy &ArgAccessorFuncCB, DebugLoc OutlinedFnLoc) |
| static Error | emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, Value *RTLocOverride, OpenMPIRBuilder::InsertPointTy AllocaIP, ArrayRef< BasicBlock * > DeallocBlocks, OpenMPIRBuilder::TargetDataInfo &Info, const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs, const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID, SmallVectorImpl< Value * > &Args, OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB, OpenMPIRBuilder::CustomMapperCallbackTy CustomMapperCB, const OpenMPIRBuilder::DependenciesInfo &Dependencies, bool HasNoWait, Value *DynCGroupMem, OMPDynGroupprivateFallbackType DynCGroupMemFallback) |
| static AtomicOrdering | TransformReleaseAcquireRelease (AtomicOrdering AO) |
| static std::string | mangleVectorParameters (ArrayRef< llvm::OpenMPIRBuilder::DeclareSimdAttrTy > ParamAttrs) |
| Mangle the parameter part of the vector function name according to their OpenMP classification. | |
| template<typename T> | |
| static void | addAArch64VectorName (T VLEN, StringRef LMask, StringRef Prefix, char ISA, StringRef ParSeq, StringRef MangledName, bool OutputBecomesInput, llvm::Function *Fn) |
| static void | addAArch64AdvSIMDNDSNames (unsigned NDS, StringRef Mask, StringRef Prefix, char ISA, StringRef ParSeq, StringRef MangledName, bool OutputBecomesInput, llvm::Function *Fn) |
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< bool > | UseDefaultMaxThreads ("openmp-ir-builder-use-default-max-threads", cl::Hidden, cl::desc("Use a default max threads if none is provided."), cl::init(true)) |
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 60 of file OMPIRBuilder.cpp.
| #define OMP_ARRAY_TYPE | ( | VarName, | |
| ElemTy, | |||
| ArraySize ) |
| #define OMP_ATTRS_SET | ( | VarName, | |
| AttrSet ) |
| #define OMP_CANCEL_KIND | ( | Enum, | |
| Str, | |||
| DirectiveEnum, | |||
| Value ) |
| #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_ATTRS | ( | Enum, | |
| FnAttrSet, | |||
| RetAttrSet, | |||
| ArgAttrSets ) |
| #define OMP_STRUCT_TYPE | ( | VarName, | |
| StructName, | |||
| Packed, | |||
| ... ) |
| #define OMP_TYPE | ( | VarName, | |
| InitValue ) |
|
static |
Definition at line 13238 of file OMPIRBuilder.cpp.
References addAArch64VectorName(), and llvm_unreachable.
Referenced by llvm::OpenMPIRBuilder::emitAArch64DeclareSimdFunction().
|
static |
Definition at line 13223 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), and T.
Referenced by addAArch64AdvSIMDNDSNames(), and llvm::OpenMPIRBuilder::emitAArch64DeclareSimdFunction().
|
static |
Attach llvm.access.group metadata to the memref instructions of Block.
Definition at line 7602 of file OMPIRBuilder.cpp.
References llvm::omp::AccessGroup, llvm::Block, and I.
Referenced by applyParallelAccessesMetadata().
|
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 7567 of file OMPIRBuilder.cpp.
References llvm::append_range(), llvm::drop_begin(), 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().
|
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 7591 of file OMPIRBuilder.cpp.
References addBasicBlockMetadata(), and assert().
Referenced by llvm::OpenMPIRBuilder::applySimd(), and llvm::OpenMPIRBuilder::unrollLoopPartial().
|
static |
Definition at line 6248 of file OMPIRBuilder.cpp.
References llvm::omp::AccessGroup, addAccessGroupMetadata(), llvm::Block, llvm::MDNode::get(), llvm::MDString::get(), llvm::LoopBase< BlockT, LoopT >::getBlocks(), llvm::CanonicalLoopInfo::getCond(), llvm::MDNode::getDistinct(), llvm::CanonicalLoopInfo::getHeader(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::OpenMPIRBuilder::applySimd().
|
static |
Definition at line 4772 of file OMPIRBuilder.cpp.
References assert().
Referenced by llvm::OpenMPIRBuilder::createReductions(), and llvm::OpenMPIRBuilder::createReductionsGPU().
|
static |
Determine the schedule type using schedule and ordering clause arguments.
Definition at line 285 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, | ||
| bool | Is64Bit = false ) |
Definition at line 450 of file OMPIRBuilder.cpp.
References llvm::cast(), llvm::AllocaInst::getAddressSpace(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::OpenMPIRBuilder::createTask(), llvm::OpenMPIRBuilder::createTeams(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 9337 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::begin(), llvm::OpenMPIRBuilder::Config, llvm::OpenMPIRBuilder::ConstantAllocaRaiseCandidates, llvm::convertUsersOfConstantsToInstructions(), llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::OpenMPIRBuilder::createTargetDeinit(), llvm::OpenMPIRBuilder::createTargetInit(), llvm::dyn_cast(), llvm::OpenMPIRBuilder::emitKernelEnvironment(), llvm::OpenMPIRBuilder::emitKernelExecutionMode(), llvm::OpenMPIRBuilder::emitUsed(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs::ExecFlags, FixupDebugInfoForOutlinedFunction(), llvm::FunctionType::get(), llvm::Argument::getArgNo(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::BasicBlock::getFirstNonPHIOrPseudoProbe(), llvm::Function::getFnAttribute(), llvm::Type::getInt64Ty(), llvm::GlobalValue::getParent(), llvm::PointerType::getUnqual(), llvm::GlobalValue::InternalLinkage, llvm::isa(), llvm::OpenMPIRBuilderConfig::isTargetDevice(), llvm::make_early_inc_range(), llvm::make_range(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), removeASCastIfPresent(), llvm::splitBB(), llvm::Expected< T >::takeError(), Users, and llvm::zip().
Referenced by emitTargetOutlinedFunction().
|
static |
Definition at line 6520 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Builder, llvm::OpenMPIRBuilder::createRuntimeFunctionCall(), llvm::BasicBlock::end(), getKmpcForStaticLoopForType(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm::Value::getType(), llvm::OpenMPIRBuilder::M, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by workshareLoopTargetCallback().
|
static |
Create wrapper function used to gather the outlined function's argument structure from a shared buffer and to forward them to it when running in Generic mode.
The outlined function is expected to receive 2 integer arguments followed by an optional pointer argument to an argument structure holding the rest.
Definition at line 1653 of file OMPIRBuilder.cpp.
References llvm::Function::arg_size(), assert(), llvm::OpenMPIRBuilder::Builder, llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::FunctionType::get(), llvm::Module::getContext(), llvm::Value::getName(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(), llvm::GlobalValue::InternalLinkage, and llvm::OpenMPIRBuilder::M.
Referenced by targetParallelCallback().
|
static |
Definition at line 9684 of file OMPIRBuilder.cpp.
References llvm::append_range(), assert(), llvm::StructType::create(), llvm::ArrayRef< T >::empty(), getOffloadingArrayType(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and V.
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 5456 of file OMPIRBuilder.cpp.
References Call.
Referenced by llvm::OpenMPIRBuilder::emitScanReduction().
|
static |
Definition at line 10159 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Builder, llvm::cantFail(), llvm::OpenMPIRBuilder::createRuntimeFunctionCall(), llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::DeviceID, llvm::OpenMPIRBuilder::emitIfClause(), llvm::OpenMPIRBuilder::emitKernelLaunch(), llvm::OpenMPIRBuilder::emitOffloadingArraysAndArgs(), llvm::OpenMPIRBuilder::emitTargetTask(), llvm::OpenMPIRBuilder::DependenciesInfo::empty(), llvm::Constant::getNullValue(), llvm::OpenMPIRBuilder::getOrCreateDefaultSrcLocStr(), llvm::OpenMPIRBuilder::getOrCreateIdent(), llvm::PointerType::getUnqual(), llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::LoopTripCount, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs::MaxTeams, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::MaxTeams, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::MaxThreads, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::IRBuilderBase::restoreIP(), llvm::OpenMPIRBuilder::TargetKernelArgs::RTArgs, llvm::IRBuilderBase::saveIP(), llvm::Error::success(), llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::TargetThreadLimit, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::TeamsThreadLimit, and llvm::zip_equal().
Referenced by llvm::OpenMPIRBuilder::createTarget().
|
static |
Definition at line 9706 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. NumOffloadingArrays is the number of offloading arrays that we need to copy into the task structure so that the deferred target task can access this data even after the stack frame of the generating task has been rolled back. Offloading arrays contain base pointers, pointers, sizes etc of the data that the target kernel will access. These in effect are the non-empty arrays of pointers held by OpenMPIRBuilder::TargetDataRTArgs.
Definition at line 9553 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::cast(), llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::OpenMPIRBuilder::createRuntimeFunctionCall(), llvm::dyn_cast(), llvm::FunctionType::get(), llvm::AllocaInst::getAlign(), llvm::AllocaInst::getAllocatedType(), llvm::AllocaInst::getAllocationSize(), llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledFunction(), llvm::Type::getInt32Ty(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getPointerAlignment(), llvm::GlobalValue::InternalLinkage, loadSharedDataFromTaskDescriptor(), llvm::OpenMPIRBuilder::M, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::Value::setName(), and uint64_t.
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 2380 of file OMPIRBuilder.cpp.
References llvm::sampleprof::Base, llvm::OpenMPIRBuilder::Builder, llvm::OpenMPIRBuilder::emitTaskDependency(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::enumerate(), llvm::ArrayType::get(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by llvm::OpenMPIRBuilder::createTask(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 9242 of file OMPIRBuilder.cpp.
References assert(), llvm::BasicBlock::back(), llvm::OpenMPIRBuilder::Config, llvm::dyn_cast(), llvm::BasicBlock::empty(), llvm::filterDbgVars(), llvm::MDNode::get(), llvm::DIVariable::getAlignInBits(), llvm::DILocalVariable::getAnnotations(), llvm::DILocalVariable::getArg(), llvm::DIScope::getFile(), llvm::DIVariable::getFile(), llvm::DILocalVariable::getFlags(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DIVariable::getLine(), llvm::DIVariable::getName(), llvm::BasicBlock::getParent(), llvm::DILocalVariable::getScope(), llvm::DIVariable::getType(), I, llvm::BasicBlock::insertDbgRecordBefore(), instructions, llvm::isa(), llvm::OpenMPIRBuilderConfig::isTargetDevice(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by createOutlinedFunction().
Definition at line 5168 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 180 of file OMPIRBuilder.cpp.
References llvm::StringRef::count(), llvm::omp::getAMDGPUGridValues(), llvm_unreachable, llvm::omp::NVPTXGridValues, llvm::omp::SPIRVGridValues, and T.
Referenced by llvm::OpenMPIRBuilder::createReductionsGPU(), and llvm::OpenMPIRBuilder::emitKernelEnvironment().
|
static |
Definition at line 3347 of file OMPIRBuilder.cpp.
|
static |
Definition at line 6072 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
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 6872 of file OMPIRBuilder.cpp.
References 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 6841 of file OMPIRBuilder.cpp.
References 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 6857 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 6088 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 6482 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm_unreachable, and llvm::OpenMPIRBuilder::M.
Referenced by createTargetLoopWorkshareCall().
Definition at line 9659 of file OMPIRBuilder.cpp.
References llvm::dyn_cast(), GEP, llvm_unreachable, and V.
Referenced by createTaskWithPrivatesTy(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Determine which scheduling algorithm to use, determined from schedule clause arguments.
Definition at line 198 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 249 of file OMPIRBuilder.cpp.
References assert(), and llvm::omp::ModifierMask.
Referenced by computeOpenMPScheduleType().
|
static |
Adds ordering modifier flags to schedule type.
Definition at line 225 of file OMPIRBuilder.cpp.
References assert(), and llvm::omp::OrderingModifier.
Referenced by computeOpenMPScheduleType().
|
static |
Given a function, if it represents the entry point of a target kernel, this returns the execution mode flags associated with that kernel.
Definition at line 304 of file OMPIRBuilder.cpp.
References Call, llvm::cast(), llvm::dyn_cast(), llvm::CallBase::getArgOperand(), and llvm::GlobalVariable::getInitializer().
Referenced by isGenericKernel().
Definition at line 176 of file OMPIRBuilder.cpp.
References T.
Referenced by llvm::OpenMPIRBuilder::emitKernelEnvironment().
|
static |
Definition at line 869 of file OMPIRBuilder.cpp.
References llvm::Block, llvm::dyn_cast(), llvm::AllocaInst::isArrayAllocation(), llvm::Instruction::moveBefore(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::OpenMPIRBuilder::finalize(), and hoistNonEntryAllocasToEntryBlock().
|
static |
Definition at line 891 of file OMPIRBuilder.cpp.
References hoistNonEntryAllocasToEntryBlock(), and llvm::DominatorTreeBase< NodeT, IsPostDom >::properlyDominates().
|
static |
Definition at line 1829 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), llvm::Function::addParamAttr(), llvm::SmallVectorImpl< T >::append(), llvm::CallBase::arg_begin(), llvm::Function::arg_begin(), llvm::CallBase::arg_end(), llvm::Function::arg_size(), assert(), llvm::OpenMPIRBuilder::Builder, llvm::cast(), Cond, llvm::MDBuilder::createCallbackEncoding(), llvm::OpenMPIRBuilder::createRuntimeFunctionCall(), llvm::dbgs(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), F, llvm::MDNode::get(), llvm::CallBase::getArgOperand(), llvm::FunctionCallee::getCallee(), llvm::Constant::getNullValue(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, llvm::isa(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::Value::user_back().
Referenced by llvm::OpenMPIRBuilder::createParallel().
|
static |
Definition at line 4794 of file OMPIRBuilder.cpp.
References llvm::all_of(), and llvm::OpenMPIRBuilder::ReductionInfo::AtomicReductionGen.
Referenced by llvm::OpenMPIRBuilder::createReductionsGPU().
|
static |
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 81 of file OMPIRBuilder.cpp.
Referenced by llvm::OpenMPIRBuilder::createAtomicUpdate(), llvm::OpenMPIRBuilder::createParallel(), and llvm::OpenMPIRBuilder::createSections().
Definition at line 333 of file OMPIRBuilder.cpp.
References getTargetKernelExecMode(), and llvm::omp::OMP_TGT_EXEC_MODE_GENERIC.
Referenced by llvm::OpenMPIRBuilder::createParallel(), and targetParallelCallback().
|
static |
Definition at line 88 of file OMPIRBuilder.cpp.
Referenced by computeOpenMPScheduleType().
|
static |
Given a task descriptor, TaskWithPrivates, return the pointer to the block of pointers containing shared data between the parent task and the created task.
Definition at line 9537 of file OMPIRBuilder.cpp.
References llvm::PointerType::getUnqual().
Referenced by llvm::OpenMPIRBuilder::emitTargetTask(), and emitTargetTaskProxyFunction().
|
static |
Mangle the parameter part of the vector function name according to their OpenMP classification.
The mangling function is defined in section 4.5 of the AAVFABI(2021Q1).
Definition at line 13126 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Linear, llvm::OpenMPIRBuilder::LinearRef, llvm::OpenMPIRBuilder::LinearUVal, llvm::OpenMPIRBuilder::LinearVal, ParamAttr, llvm::OpenMPIRBuilder::Uniform, and llvm::OpenMPIRBuilder::Vector.
Referenced by llvm::OpenMPIRBuilder::emitAArch64DeclareSimdFunction(), and llvm::OpenMPIRBuilder::emitX86DeclareSimdFunction().
|
static |
Definition at line 5177 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::Create(), llvm::OpenMPIRBuilder::ReductionInfo::ElementType, llvm::enumerate(), llvm::ArrayType::get(), llvm::Function::getArg(), llvm::Module::getContext(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::Value::getType(), LHS, llvm::OpenMPIRBuilder::ReductionInfo::PrivateVariable, llvm::OpenMPIRBuilder::ReductionInfo::ReductionGen, RHS, llvm::ArrayRef< T >::size(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::OpenMPIRBuilder::ReductionInfo::Variable.
Referenced by llvm::OpenMPIRBuilder::createReductions().
|
static |
Definition at line 846 of file OMPIRBuilder.cpp.
References llvm::Function::begin(), llvm::Block, llvm::dyn_cast_if_present(), llvm::Function::end(), llvm::AllocaInst::getArraySize(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::isa(), 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 7020 of file OMPIRBuilder.cpp.
References DL, llvm::make_early_inc_range(), Pred, llvm::predecessors(), and redirectTo().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), llvm::OpenMPIRBuilder::fuseLoops(), 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 345 of file OMPIRBuilder.cpp.
References llvm::cast(), llvm::UncondBrInst::Create(), DL, and llvm::BasicBlock::removePredecessor().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), llvm::OpenMPIRBuilder::createIteratorLoop(), llvm::OpenMPIRBuilder::fuseLoops(), redirectAllPredecessorsTo(), and llvm::OpenMPIRBuilder::tileLoops().
Definition at line 9331 of file OMPIRBuilder.cpp.
References llvm::cast(), llvm::Operator::getOpcode(), and V.
Referenced by createOutlinedFunction().
|
static |
Definition at line 7026 of file OMPIRBuilder.cpp.
References Changed, llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::DeleteDeadBlocks(), llvm::dyn_cast(), llvm::filter_to_vector(), llvm::from_range, llvm::BasicBlock::getParent(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::Value::uses().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), llvm::OpenMPIRBuilder::fuseLoops(), and llvm::OpenMPIRBuilder::tileLoops().
|
static |
This is a wrapper over IRBuilderBase::restoreIP that also restores a current debug location when the insert point is at the end of a block.
It picks a location scoped to the current function: the block's last instruction location if the block is non-empty, otherwise a location synthesized from the function's subprogram (when the function has debug info).
Definition at line 154 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::back(), llvm::BasicBlock::empty(), llvm::BasicBlock::end(), llvm::MDNode::get(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getParent(), and llvm::Function::getSubprogram().
Referenced by llvm::OpenMPIRBuilder::createTargetData(), and llvm::OpenMPIRBuilder::emitOffloadingArrays().
|
static |
Definition at line 1731 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), llvm::Function::addParamAttr(), llvm::CallBase::arg_begin(), llvm::Function::arg_begin(), llvm::Function::arg_size(), assert(), llvm::OpenMPIRBuilder::Builder, llvm::cast(), Cond, llvm::OpenMPIRBuilder::createRuntimeFunctionCall(), createTargetParallelWrapper(), llvm::dbgs(), llvm::Instruction::eraseFromParent(), llvm::ArrayType::get(), llvm::AllocaInst::getAddressSpace(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Constant::getNullValue(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, isGenericKernel(), LLVM_DEBUG, llvm::Value::user_back(), and V.
Referenced by llvm::OpenMPIRBuilder::createParallel().
|
static |
Definition at line 11669 of file OMPIRBuilder.cpp.
References llvm::Acquire, llvm::AcquireRelease, llvm::Monotonic, and llvm::Release.
Definition at line 8836 of file OMPIRBuilder.cpp.
References llvm::utostr().
Referenced by llvm::OpenMPIRBuilder::writeThreadBoundsForKernel().
|
static |
Definition at line 6560 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::BasicBlock::begin(), llvm::OpenMPIRBuilder::Builder, llvm::OpenMPIRBuilder::OutlineInfo::collectBlocks(), createTargetLoopWorkshareCall(), llvm::DeleteDeadBlocks(), llvm::dyn_cast(), 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::BasicBlock::getTerminator(), llvm::CanonicalLoopInfo::getTripCount(), llvm::Value::getUniqueUndroppableUser(), llvm::CanonicalLoopInfo::invalidate(), and llvm::BasicBlock::splice().
|
static |
|
static |
Referenced by llvm::OpenMPIRBuilder::emitKernelEnvironment().