aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
diff options
context:
space:
mode:
authorShraiysh Vaishay <Shraiysh.Vaishay@amd.com>2021-12-15 15:23:30 +0530
committerShraiysh Vaishay <Shraiysh.Vaishay@amd.com>2021-12-15 15:41:12 +0530
commit3425b1bcb4bf6eee57a18f872511403c2d26d166 (patch)
tree9e07ef163654f162fbe19858a214395550686ff1 /llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
parent529833377ccdf4381f8bc9961bfa96ec4f5e2eed (diff)
downloadllvm-3425b1bcb4bf6eee57a18f872511403c2d26d166.zip
llvm-3425b1bcb4bf6eee57a18f872511403c2d26d166.tar.gz
llvm-3425b1bcb4bf6eee57a18f872511403c2d26d166.tar.bz2
[mlir][OpenMP] omp.sections and omp.section lowering to LLVM IR
This patch adds lowering from omp.sections and omp.section (simple lowering along with the nowait clause) to LLVM IR. Tests for the same are also added. Reviewed By: ftynse, kiranchandramohan Differential Revision: https://reviews.llvm.org/D115030
Diffstat (limited to 'llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp')
-rw-r--r--llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 454dbb5..fba36d4 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -3637,6 +3637,34 @@ TEST_F(OpenMPIRBuilderTest, CreateSections) {
EXPECT_FALSE(verifyModule(*M, &errs()));
}
+TEST_F(OpenMPIRBuilderTest, CreateSectionsNoWait) {
+ using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+ using BodyGenCallbackTy = llvm::OpenMPIRBuilder::StorableBodyGenCallbackTy;
+ OpenMPIRBuilder OMPBuilder(*M);
+ OMPBuilder.initialize();
+ F->setName("func");
+ IRBuilder<> Builder(BB);
+
+ OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+ IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+ F->getEntryBlock().getFirstInsertionPt());
+ llvm::SmallVector<BodyGenCallbackTy, 4> SectionCBVector;
+ auto PrivCB = [](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+ llvm::Value &, llvm::Value &Val,
+ llvm::Value *&ReplVal) { return CodeGenIP; };
+ auto FiniCB = [&](InsertPointTy IP) {};
+
+ Builder.restoreIP(OMPBuilder.createSections(Loc, AllocaIP, SectionCBVector,
+ PrivCB, FiniCB, false, true));
+ Builder.CreateRetVoid(); // Required at the end of the function
+ for (auto &Inst : instructions(*F)) {
+ EXPECT_FALSE(isa<CallInst>(Inst) &&
+ cast<CallInst>(&Inst)->getCalledFunction()->getName() ==
+ "__kmpc_barrier" &&
+ "call to function __kmpc_barrier found with nowait");
+ }
+}
+
TEST_F(OpenMPIRBuilderTest, CreateOffloadMaptypes) {
OpenMPIRBuilder OMPBuilder(*M);
OMPBuilder.initialize();