[PATCH] D92849: [OpenMPIRBuilder] Put the barrier in the exit block in createWorkshapeLoop
Alex Zinenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 07:45:12 PST 2020
ftynse created this revision.
ftynse added reviewers: jdoerfert, Meinersbur.
Herald added subscribers: guansong, hiraditya, yaxunl.
ftynse requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
The original code was inserting the barrier at the location given by the
caller. Make sure it is always inserted at the end of the loop exit block
instead.
Depends On D92845 <https://reviews.llvm.org/D92845>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92849
Files:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===================================================================
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1155,6 +1155,11 @@
// increment and in the statement that adds the lower bound to it.
Value *IV = CLI->getIndVar();
EXPECT_EQ(std::distance(IV->use_begin(), IV->use_end()), 3);
+
+ // The exit block should contain the "fini" call and the barrier call.
+ BasicBlock *ExitBlock = CLI->getExitBlock();
+ EXPECT_EQ(
+ count_if(*ExitBlock, [](Instruction *I) { return isa<CallInst>(I); }), 2);
}
TEST_F(OpenMPIRBuilderTest, MasterDirective) {
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1104,7 +1104,8 @@
// Add the barrier if requested.
if (NeedsBarrier)
- createBarrier(Loc, omp::Directive::OMPD_for, /* ForceSimpleCall */ false,
+ createBarrier(LocationDescription(Builder.saveIP(), Loc.DL),
+ omp::Directive::OMPD_for, /* ForceSimpleCall */ false,
/* CheckCancelFlag */ false);
CLI->assertOK();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92849.310209.patch
Type: text/x-patch
Size: 1270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201208/f0bc3393/attachment.bin>
More information about the llvm-commits
mailing list