aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
diff options
context:
space:
mode:
authorAkash Banerjee <akash.banerjee@amd.com>2024-03-19 13:04:23 +0000
committerGitHub <noreply@github.com>2024-03-19 13:04:23 +0000
commite9da5f0083d12a7284c780e916c17b6a2785933e (patch)
tree21c38e21882b6b84cda6782c8fb034014d965eb5 /llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
parent930f21c6bc0fe05c1d08be6353f7c7c6c51f4dc0 (diff)
downloadllvm-e9da5f0083d12a7284c780e916c17b6a2785933e.zip
llvm-e9da5f0083d12a7284c780e916c17b6a2785933e.tar.gz
llvm-e9da5f0083d12a7284c780e916c17b6a2785933e.tar.bz2
[OpenMP] Fix target data region codegen being omitted for device pass (#85218)
This patch enables the BodyCodeGen callback to still trigger for the TargetData nested region during the device pass. There maybe Target code nested within the TargetData region for which this is required. Also add tests for the same.
Diffstat (limited to 'llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp')
-rw-r--r--llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index fdbe8df..5c415ca 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5856,6 +5856,23 @@ TEST_F(OpenMPIRBuilderTest, TargetDataRegion) {
EXPECT_TRUE(TargetDataCall->getOperand(2)->getType()->isIntegerTy(32));
EXPECT_TRUE(TargetDataCall->getOperand(8)->getType()->isPointerTy());
+ // Check that BodyGenCB is still made when IsTargetDevice is set to true.
+ OMPBuilder.Config.setIsTargetDevice(true);
+ bool CheckDevicePassBodyGen = false;
+ auto BodyTargetCB = [&](InsertPointTy CodeGenIP, BodyGenTy BodyGenType) {
+ CheckDevicePassBodyGen = true;
+ Builder.restoreIP(CodeGenIP);
+ CallInst *TargetDataCall =
+ dyn_cast<CallInst>(BB->back().getPrevNode()->getPrevNode());
+ // Make sure no begin_mapper call is present for device pass.
+ EXPECT_EQ(TargetDataCall, nullptr);
+ return Builder.saveIP();
+ };
+ Builder.restoreIP(OMPBuilder.createTargetData(
+ Loc, AllocaIP, Builder.saveIP(), Builder.getInt64(DeviceID),
+ /* IfCond= */ nullptr, Info, GenMapInfoCB, nullptr, BodyTargetCB));
+ EXPECT_TRUE(CheckDevicePassBodyGen);
+
Builder.CreateRetVoid();
EXPECT_FALSE(verifyModule(*M, &errs()));
}