[PATCH] D70712: [WIP][NFC] Adding Flush support in OpenMPIRBuilder
Kiran Chandramohan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 04:51:42 PST 2019
kiranchandramohan created this revision.
kiranchandramohan added reviewers: jdoerfert, rogfer01.
Herald added subscribers: llvm-commits, guansong, hiraditya.
Herald added a project: LLVM.
This patch adds support for the Flush construct in the OpenMPIRBuilder introduced in https://reviews.llvm.org/D69785. The change is closely based on https://reviews.llvm.org/D69828.
https://reviews.llvm.org/D70712
Files:
clang/lib/CodeGen/CGOpenMPRuntime.cpp
llvm/include/llvm/Frontend/OpenMPKinds.def
llvm/include/llvm/Transforms/Utils/OpenMPIRBuilder.h
llvm/lib/Frontend/OpenMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMPIRBuilder.cpp
@@ -243,3 +243,15 @@
return Builder.saveIP();
}
+
+void OpenMPIRBuilder::emitFlush(const LocationDescription &Loc)
+{
+ assert(Loc.IP.getBlock() && "No insertion point provided!");
+ Builder.restoreIP(Loc.IP);
+
+ // Build call void __kmpc_flush(ident_t *loc)
+ Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+ Value *Args[] = {getOrCreateIdent(SrcLocStr)};
+
+ Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_flush), Args);
+}
Index: llvm/include/llvm/Transforms/Utils/OpenMPIRBuilder.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/OpenMPIRBuilder.h
+++ llvm/include/llvm/Transforms/Utils/OpenMPIRBuilder.h
@@ -75,6 +75,12 @@
///}
+ /// Generate a flush runtime call.
+ ///
+ /// \param Loc The location at which the request originated and is fulfilled.
+ void emitFlush(const LocationDescription &Loc);
+
+
private:
/// Update the internal location to \p Loc.
bool updateToLocation(const LocationDescription &Loc) {
Index: llvm/include/llvm/Frontend/OpenMPKinds.def
===================================================================
--- llvm/include/llvm/Frontend/OpenMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMPKinds.def
@@ -164,6 +164,7 @@
__OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32)
__OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_flush, false, Void, IdentPtr)
__OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
__OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
__OMP_RTL(omp_get_thread_num, false, Int32, )
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3873,9 +3873,14 @@
SourceLocation Loc) {
if (!CGF.HaveInsertPoint())
return;
- // Build call void __kmpc_flush(ident_t *loc)
- CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_flush),
- emitUpdateLocation(CGF, Loc));
+ llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+ if (OMPBuilder)
+ OMPBuilder->emitFlush({CGF.Builder.saveIP()});
+ else {
+ // Build call void __kmpc_flush(ident_t *loc)
+ CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_flush),
+ emitUpdateLocation(CGF, Loc));
+ }
}
namespace {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70712.231043.patch
Type: text/x-patch
Size: 2644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191126/d6a3ccf6/attachment.bin>
More information about the llvm-commits
mailing list