LLVM 22.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/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/InstIterator.h"
#include "llvm/IR/IntrinsicInst.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_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 void | restoreIPandDebugLoc (llvm::IRBuilderBase &Builder, llvm::IRBuilderBase::InsertPoint IP) |
This is wrapper over IRBuilderBase::restoreIP that also restores the current debug location to the last instruction in the specified basic block if the insert point points to the end of the block. | |
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 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 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) |
static void | workshareLoopTargetCallback (OpenMPIRBuilder *OMPIRBuilder, CanonicalLoopInfo *CLI, Value *Ident, Function &OutlinedFn, 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 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 Expected< Function * > | createOutlinedFunction (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs, StringRef FuncName, SmallVectorImpl< Value * > &Inputs, OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc, OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy &ArgAccessorFuncCB) |
static LoadInst * | loadSharedDataFromTaskDescriptor (OpenMPIRBuilder &OMPIRBuilder, IRBuilderBase &Builder, Value *TaskWithPrivates, Type *TaskWithPrivatesTy) |
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) |
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) |
static void | emitTargetCall (OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, OpenMPIRBuilder::InsertPointTy AllocaIP, 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 SmallVector< llvm::OpenMPIRBuilder::DependData > &Dependencies, bool HasNoWait) |
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 64 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_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 5740 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().
|
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 5764 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 5775 of file OMPIRBuilder.cpp.
References llvm::Block, and I.
Referenced by llvm::OpenMPIRBuilder::applySimd().
|
static |
Definition at line 3532 of file OMPIRBuilder.cpp.
References assert().
Referenced by llvm::OpenMPIRBuilder::createReductions(), and 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 6044 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 267 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 393 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 7407 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(), llvm::OpenMPIRBuilder::emitKernelExecutionMode(), llvm::OpenMPIRBuilder::emitUsed(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs::ExecFlags, FixupDebugInfoForOutlinedFunction(), llvm::FunctionType::get(), llvm::Argument::getArgNo(), llvm::IRBuilderBase::getContext(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::Function::getFnAttribute(), llvm::IRBuilderBase::GetInsertBlock(), llvm::Type::getInt64Ty(), llvm::BasicBlock::getParent(), 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(), Users, and llvm::zip().
Referenced by emitTargetOutlinedFunction().
|
static |
Definition at line 4966 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Builder, llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateZExtOrTrunc(), llvm::BasicBlock::end(), llvm::IRBuilderBase::getInt8Ty(), 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 6023 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 7755 of file OMPIRBuilder.cpp.
References assert(), llvm::StructType::create(), llvm::ArrayRef< T >::empty(), getOffloadingArrayType(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 4040 of file OMPIRBuilder.cpp.
References llvm::IRBuilderBase::CreateCall(), and Name.
Referenced by llvm::OpenMPIRBuilder::emitScanReduction().
|
static |
Definition at line 8194 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Builder, llvm::cantFail(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateICmpULT(), llvm::IRBuilderBase::CreateIntCast(), llvm::IRBuilderBase::CreateSelect(), DefaultVal, llvm::OpenMPIRBuilder::emitIfClause(), llvm::OpenMPIRBuilder::emitKernelLaunch(), llvm::OpenMPIRBuilder::emitOffloadingArraysAndArgs(), llvm::OpenMPIRBuilder::emitTargetTask(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt64(), llvm::IRBuilderBase::getInt64Ty(), llvm::OpenMPIRBuilder::getOrCreateDefaultSrcLocStr(), llvm::OpenMPIRBuilder::getOrCreateIdent(), Info, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::LoopTripCount, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs::MaxTeams, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::MaxTeams, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::MaxThreads, llvm::omp::OMP_DEVICEID_UNDEF, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::IRBuilderBase::restoreIP(), llvm::OpenMPIRBuilder::TargetKernelArgs::RTArgs, llvm::IRBuilderBase::saveIP(), llvm::SmallVectorBase< Size_T >::size(), llvm::Error::success(), llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::TargetThreadLimit, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs::TeamsThreadLimit, and llvm::zip_equal().
Referenced by llvm::OpenMPIRBuilder::createTarget().
|
static |
Definition at line 7775 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 7626 of file OMPIRBuilder.cpp.
References llvm::CallBase::arg_size(), assert(), llvm::Function::Create(), llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateCall(), 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::IRBuilderBase::getVoidTy(), llvm::GlobalValue::InternalLinkage, loadSharedDataFromTaskDescriptor(), llvm::OpenMPIRBuilder::M, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::Value::setName().
Referenced by llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 1863 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::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::createTask(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Definition at line 7344 of file OMPIRBuilder.cpp.
References llvm::OpenMPIRBuilder::Config, llvm::filterDbgVars(), llvm::MDNode::get(), llvm::DIVariable::getAlignInBits(), llvm::DILocalVariable::getAnnotations(), llvm::DILocalVariable::getArg(), llvm::IRBuilderBase::getContext(), llvm::DIScope::getFile(), llvm::DIVariable::getFile(), llvm::DILocalVariable::getFlags(), llvm::DIVariable::getLine(), llvm::DIVariable::getName(), llvm::DILocalVariable::getScope(), llvm::DIVariable::getType(), I, instructions, and llvm::OpenMPIRBuilderConfig::isTargetDevice().
Referenced by createOutlinedFunction().
Definition at line 3758 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 165 of file OMPIRBuilder.cpp.
References llvm::StringRef::count(), llvm::Function::getFnAttribute(), llvm::Attribute::getValueAsString(), llvm_unreachable, llvm::omp::NVPTXGridValues, and llvm::omp::SPIRVGridValues.
Referenced by llvm::OpenMPIRBuilder::createReductionsGPU(), and llvm::OpenMPIRBuilder::createTargetInit().
|
static |
Definition at line 2365 of file OMPIRBuilder.cpp.
|
static |
Definition at line 4633 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), 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 5243 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 5212 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 5228 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 4649 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), and llvm_unreachable.
|
static |
Definition at line 4928 of file OMPIRBuilder.cpp.
References llvm::Type::getIntegerBitWidth(), llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(), llvm_unreachable, and llvm::OpenMPIRBuilder::M.
Referenced by createTargetLoopWorkshareCall().
Definition at line 7730 of file OMPIRBuilder.cpp.
References GEP, and llvm_unreachable.
Referenced by createTaskWithPrivatesTy(), and llvm::OpenMPIRBuilder::emitTargetTask().
|
static |
Determine which scheduling algorithm to use, determined from schedule clause arguments.
Definition at line 183 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 231 of file OMPIRBuilder.cpp.
References assert(), and llvm::omp::ModifierMask.
Referenced by computeOpenMPScheduleType().
|
static |
Adds ordering modifier flags to schedule type.
Definition at line 207 of file OMPIRBuilder.cpp.
References assert().
Referenced by computeOpenMPScheduleType().
|
static |
Definition at line 1404 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::OpenMPIRBuilder::Builder, Cond, 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 87 of file OMPIRBuilder.cpp.
Referenced by llvm::OpenMPIRBuilder::createAtomicUpdate(), llvm::OpenMPIRBuilder::createParallel(), and llvm::OpenMPIRBuilder::createSections().
|
static |
Definition at line 94 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 7592 of file OMPIRBuilder.cpp.
References llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateStructGEP(), llvm::IRBuilderBase::getContext(), and llvm::PointerType::getUnqual().
Referenced by llvm::OpenMPIRBuilder::emitTargetTask(), and emitTargetTaskProxyFunction().
|
static |
Definition at line 3767 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::Create(), llvm::IRBuilderBase::CreateAlloca(), llvm::IRBuilderBase::CreateConstInBoundsGEP2_64(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreatePointerBitCastOrAddrSpaceCast(), llvm::IRBuilderBase::CreateRetVoid(), llvm::IRBuilderBase::CreateStore(), llvm::OpenMPIRBuilder::ReductionInfo::ElementType, llvm::enumerate(), llvm::ArrayType::get(), llvm::Function::getArg(), llvm::Module::getContext(), llvm::IRBuilderBase::GetInsertBlock(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::IRBuilderBase::getPtrTy(), llvm::Value::getType(), LHS, llvm::OpenMPIRBuilder::ReductionInfo::PrivateVariable, llvm::OpenMPIRBuilder::ReductionInfo::ReductionGen, llvm::IRBuilderBase::restoreIP(), RHS, llvm::IRBuilderBase::saveIP(), llvm::IRBuilderBase::SetInsertPoint(), 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 680 of file OMPIRBuilder.cpp.
References llvm::Function::begin(), llvm::Block, llvm::Function::end(), llvm::AllocaInst::getArraySize(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIIt(), 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 5389 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 288 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 5397 of file OMPIRBuilder.cpp.
References llvm::SmallPtrSetImpl< PtrType >::begin(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::DeleteDeadBlocks(), llvm::SmallPtrSetImpl< PtrType >::end(), llvm::from_range, and llvm::SmallPtrSetImpl< PtrType >::remove_if().
Referenced by llvm::OpenMPIRBuilder::collapseLoops(), and llvm::OpenMPIRBuilder::tileLoops().
|
static |
This is wrapper over IRBuilderBase::restoreIP that also restores the current debug location to the last instruction in the specified basic block if the insert point points to the end of the block.
Definition at line 156 of file OMPIRBuilder.cpp.
References llvm::BasicBlock::back(), llvm::BasicBlock::empty(), llvm::BasicBlock::end(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::GetInsertPoint(), llvm::Instruction::getStableDebugLoc(), I, llvm::IRBuilderBase::restoreIP(), and llvm::IRBuilderBase::SetCurrentDebugLocation().
Referenced by llvm::OpenMPIRBuilder::createTargetData(), and llvm::OpenMPIRBuilder::emitOffloadingArrays().
|
static |
Definition at line 1316 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::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().
Definition at line 6931 of file OMPIRBuilder.cpp.
References llvm::Function::addFnAttr(), llvm::Function::getFnAttributeAsParsedInteger(), llvm::Function::hasFnAttribute(), and Name.
Referenced by llvm::OpenMPIRBuilder::writeThreadBoundsForKernel().
|
static |
Definition at line 5004 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().