#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/Casting.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>
usingnamespacellvm;
usingnamespaceomp;
namespace {
static CallInst *createPrintfCall(IRBuilder<> &Builder, StringRef FormatStr,
ArrayRef<Value *> Values) { … }
static testing::AssertionResult
verifyDFSOrder(Function *F, ArrayRef<BasicBlock *> RefOrder) { … }
static testing::AssertionResult
verifyListOrder(Function *F, ArrayRef<BasicBlock *> RefOrder) { … }
static void findCalls(Function *F, omp::RuntimeFunction FnID,
OpenMPIRBuilder &OMPBuilder,
SmallVectorImpl<CallInst *> &Calls) { … }
static CallInst *findSingleCall(Function *F, omp::RuntimeFunction FnID,
OpenMPIRBuilder &OMPBuilder) { … }
static omp::ScheduleKind getSchedKind(omp::OMPScheduleType SchedType) { … }
class OpenMPIRBuilderTest : public testing::Test { … };
class OpenMPIRBuilderTestWithParams
: public OpenMPIRBuilderTest,
public ::testing::WithParamInterface<omp::OMPScheduleType> { … };
class OpenMPIRBuilderTestWithIVBits
: public OpenMPIRBuilderTest,
public ::testing::WithParamInterface<int> { … };
template <typename InstTy> static Value *findStoredValue(Value *AllocaValue) { … }
static Value *findStoredValueInAggregateAt(LLVMContext &Ctx, Value *Aggregate,
unsigned Idx) { … }
static Value *findAggregateFromValue(Value *V) { … }
TEST_F(OpenMPIRBuilderTest, CreateBarrier) { … }
TEST_F(OpenMPIRBuilderTest, CreateCancel) { … }
TEST_F(OpenMPIRBuilderTest, CreateCancelIfCond) { … }
TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) { … }
TEST_F(OpenMPIRBuilderTest, DbgLoc) { … }
TEST_F(OpenMPIRBuilderTest, ParallelSimpleGPU) { … }
TEST_F(OpenMPIRBuilderTest, ParallelSimple) { … }
TEST_F(OpenMPIRBuilderTest, ParallelNested) { … }
TEST_F(OpenMPIRBuilderTest, ParallelNested2Inner) { … }
TEST_F(OpenMPIRBuilderTest, ParallelIfCond) { … }
TEST_F(OpenMPIRBuilderTest, ParallelCancelBarrier) { … }
TEST_F(OpenMPIRBuilderTest, ParallelForwardAsPointers) { … }
TEST_F(OpenMPIRBuilderTest, CanonicalLoopSimple) { … }
TEST_F(OpenMPIRBuilderTest, CanonicalLoopBounds) { … }
TEST_F(OpenMPIRBuilderTest, CollapseNestedLoops) { … }
TEST_F(OpenMPIRBuilderTest, TileSingleLoop) { … }
TEST_F(OpenMPIRBuilderTest, TileNestedLoops) { … }
TEST_F(OpenMPIRBuilderTest, TileNestedLoopsWithBounds) { … }
TEST_F(OpenMPIRBuilderTest, TileSingleLoopCounts) { … }
TEST_F(OpenMPIRBuilderTest, ApplySimd) { … }
TEST_F(OpenMPIRBuilderTest, ApplySimdCustomAligned) { … }
TEST_F(OpenMPIRBuilderTest, ApplySimdlen) { … }
TEST_F(OpenMPIRBuilderTest, ApplySafelenOrderConcurrent) { … }
TEST_F(OpenMPIRBuilderTest, ApplySafelen) { … }
TEST_F(OpenMPIRBuilderTest, ApplySimdlenSafelen) { … }
TEST_F(OpenMPIRBuilderTest, ApplySimdIf) { … }
TEST_F(OpenMPIRBuilderTest, UnrollLoopFull) { … }
TEST_F(OpenMPIRBuilderTest, UnrollLoopPartial) { … }
TEST_F(OpenMPIRBuilderTest, UnrollLoopHeuristic) { … }
TEST_F(OpenMPIRBuilderTest, StaticWorkshareLoopTarget) { … }
TEST_F(OpenMPIRBuilderTest, StaticWorkShareLoop) { … }
TEST_P(OpenMPIRBuilderTestWithIVBits, StaticChunkedWorkshareLoop) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(OpenMPIRBuilderTestWithParams, DynamicWorkShareLoop) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(OpenMPIRBuilderTest, DynamicWorkShareLoopOrdered) { … }
TEST_F(OpenMPIRBuilderTest, MasterDirective) { … }
TEST_F(OpenMPIRBuilderTest, MaskedDirective) { … }
TEST_F(OpenMPIRBuilderTest, CriticalDirective) { … }
TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSource) { … }
TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSink) { … }
TEST_F(OpenMPIRBuilderTest, OrderedDirectiveThreads) { … }
TEST_F(OpenMPIRBuilderTest, OrderedDirectiveSimd) { … }
TEST_F(OpenMPIRBuilderTest, CopyinBlocks) { … }
TEST_F(OpenMPIRBuilderTest, SingleDirective) { … }
TEST_F(OpenMPIRBuilderTest, SingleDirectiveNowait) { … }
class BBInstIter { … };
TEST_F(OpenMPIRBuilderTest, SingleDirectiveCopyPrivate) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicReadFlt) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicReadInt) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicWriteFlt) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicWriteInt) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicUpdate) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicUpdateFloat) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicUpdateIntr) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicCapture) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicCompare) { … }
TEST_F(OpenMPIRBuilderTest, OMPAtomicCompareCapture) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeams) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithThreadLimit) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithNumTeamsUpper) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithNumTeamsBoth) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithNumTeamsAndThreadLimit) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithIfCondition) { … }
TEST_F(OpenMPIRBuilderTest, CreateTeamsWithIfConditionAndNumTeams) { … }
template <typename InstTy>
static InstTy *findSingleUserInBlock(Value *V, BasicBlock *BB) { … }
static bool isSimpleBinaryReduction(Value *Accum, BasicBlock *BB,
Instruction::BinaryOps *OpCode = nullptr) { … }
static bool isValueReducedToFuncArg(Value *V, BasicBlock *BB) { … }
static bool findGEPZeroOne(Value *Ptr, Value *&Zero, Value *&One) { … }
static OpenMPIRBuilder::InsertPointTy
sumReduction(OpenMPIRBuilder::InsertPointTy IP, Value *LHS, Value *RHS,
Value *&Result) { … }
static OpenMPIRBuilder::InsertPointTy
sumAtomicReduction(OpenMPIRBuilder::InsertPointTy IP, Type *Ty, Value *LHS,
Value *RHS) { … }
static OpenMPIRBuilder::InsertPointTy
xorReduction(OpenMPIRBuilder::InsertPointTy IP, Value *LHS, Value *RHS,
Value *&Result) { … }
static OpenMPIRBuilder::InsertPointTy
xorAtomicReduction(OpenMPIRBuilder::InsertPointTy IP, Type *Ty, Value *LHS,
Value *RHS) { … }
TEST_F(OpenMPIRBuilderTest, CreateReductions) { … }
TEST_F(OpenMPIRBuilderTest, CreateTwoReductions) { … }
TEST_F(OpenMPIRBuilderTest, CreateSectionsSimple) { … }
TEST_F(OpenMPIRBuilderTest, CreateSections) { … }
TEST_F(OpenMPIRBuilderTest, CreateSectionsNoWait) { … }
TEST_F(OpenMPIRBuilderTest, CreateOffloadMaptypes) { … }
TEST_F(OpenMPIRBuilderTest, CreateOffloadMapnames) { … }
TEST_F(OpenMPIRBuilderTest, CreateMapperAllocas) { … }
TEST_F(OpenMPIRBuilderTest, EmitMapperCall) { … }
TEST_F(OpenMPIRBuilderTest, TargetEnterData) { … }
TEST_F(OpenMPIRBuilderTest, TargetExitData) { … }
TEST_F(OpenMPIRBuilderTest, TargetDataRegion) { … }
namespace {
void CreateDefaultMapInfos(llvm::OpenMPIRBuilder &OmpBuilder,
llvm::SmallVectorImpl<llvm::Value *> &Args,
llvm::OpenMPIRBuilder::MapInfosTy &CombinedInfo) { … }
}
TEST_F(OpenMPIRBuilderTest, TargetRegion) { … }
TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) { … }
TEST_F(OpenMPIRBuilderTest, ConstantAllocaRaise) { … }
TEST_F(OpenMPIRBuilderTest, CreateTask) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskNoArgs) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskUntied) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskDepend) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskFinal) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskIfCondition) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskgroup) { … }
TEST_F(OpenMPIRBuilderTest, CreateTaskgroupWithTasks) { … }
TEST_F(OpenMPIRBuilderTest, EmitOffloadingArraysArguments) { … }
TEST_F(OpenMPIRBuilderTest, OffloadEntriesInfoManager) { … }
TEST_F(OpenMPIRBuilderTest, registerTargetGlobalVariable) { … }
TEST_F(OpenMPIRBuilderTest, createGPUOffloadEntry) { … }
}