aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
diff options
context:
space:
mode:
authorPrabhdeep Singh Soni <prabhdeep.singh.soni3@huawei.com>2023-09-15 11:41:35 -0400
committerPrabhdeep Singh Soni <prabhdeep.singh.soni3@huawei.com>2023-09-15 12:19:47 -0400
commit9b57b167bb4d849b6803e28f638b970f493511f9 (patch)
treed2a5cafe95c858d9c78b2ad0c0ee8504d076e72e /llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
parent6c8243060d3d5a4812008bb846b02e63956157b1 (diff)
downloadllvm-9b57b167bb4d849b6803e28f638b970f493511f9.zip
llvm-9b57b167bb4d849b6803e28f638b970f493511f9.tar.gz
llvm-9b57b167bb4d849b6803e28f638b970f493511f9.tar.bz2
[OMPIRBuilder] Fix shared clause for task construct
This patch fixes the shared clause for the task construct with multiple shared variables. The shareds field in the kmp_task_t is not an inline array in the struct, rather it is a pointer to an array. With an inline array, the pointer dereference to the outlined function body of the task would segmentation fault when accessed by the runtime. Reviewed By: kiranchandramohan, jdoerfert Differential Revision: https://reviews.llvm.org/D158462
Diffstat (limited to 'llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp')
-rw-r--r--llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index bc1687c..2026824 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5397,19 +5397,29 @@ TEST_F(OpenMPIRBuilderTest, CreateTask) {
ConstantInt *DataSize =
dyn_cast<ConstantInt>(TaskAllocCall->getArgOperand(3));
ASSERT_NE(DataSize, nullptr);
- EXPECT_EQ(DataSize->getSExtValue(), 24); // 64-bit pointer + 128-bit integer
+ EXPECT_EQ(DataSize->getSExtValue(), 40);
- // TODO: Verify size of shared clause variables
+ ConstantInt *SharedsSize =
+ dyn_cast<ConstantInt>(TaskAllocCall->getOperand(4));
+ EXPECT_EQ(SharedsSize->getSExtValue(),
+ 24); // 64-bit pointer + 128-bit integer
// Verify Wrapper function
Function *WrapperFunc =
dyn_cast<Function>(TaskAllocCall->getArgOperand(5)->stripPointerCasts());
ASSERT_NE(WrapperFunc, nullptr);
+
+ LoadInst *SharedsLoad = dyn_cast<LoadInst>(WrapperFunc->begin()->begin());
+ ASSERT_NE(SharedsLoad, nullptr);
+ EXPECT_EQ(SharedsLoad->getPointerOperand(), WrapperFunc->getArg(1));
+
EXPECT_FALSE(WrapperFunc->isDeclaration());
- CallInst *OutlinedFnCall = dyn_cast<CallInst>(WrapperFunc->begin()->begin());
+ CallInst *OutlinedFnCall =
+ dyn_cast<CallInst>(++WrapperFunc->begin()->begin());
ASSERT_NE(OutlinedFnCall, nullptr);
EXPECT_EQ(WrapperFunc->getArg(0)->getType(), Builder.getInt32Ty());
- EXPECT_EQ(OutlinedFnCall->getArgOperand(0), WrapperFunc->getArg(1));
+ EXPECT_EQ(OutlinedFnCall->getArgOperand(0),
+ WrapperFunc->getArg(1)->uses().begin()->getUser());
// Verify the presence of `trunc` and `icmp` instructions in Outlined function
Function *OutlinedFn = OutlinedFnCall->getCalledFunction();