raghavendhra updated this revision to Diff 543696.
raghavendhra added a comment.
Addressed review comments by making setPropertyExecutionMode() to return a
Global Value instead of void. Rebased patch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155794/new/
https://reviews.llvm.org/D155794
Files:
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenModule.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4900,6 +4900,19 @@
emitBlock(ContBlock, CurFn, /*IsFinished=*/true);
}
+GlobalVariable *OpenMPIRBuilder::setPropertyExecutionMode(StringRef Name,
+ bool IsSPMDMode) {
+ auto *GVMode = new llvm::GlobalVariable(
+ M, llvm::Type::getInt8Ty(M.getContext()), /*isConstant=*/true,
+ llvm::GlobalValue::WeakAnyLinkage,
+ llvm::ConstantInt::get(llvm::Type::getInt8Ty(M.getContext()),
+ IsSPMDMode ? OMP_TGT_EXEC_MODE_SPMD
+ : OMP_TGT_EXEC_MODE_GENERIC),
+ Twine(Name, "_exec_mode"));
+ GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
+ return GVMode;
+}
+
bool OpenMPIRBuilder::checkAndEmitFlushAfterAtomic(
const LocationDescription &Loc, llvm::AtomicOrdering AO, AtomicKind AK) {
assert(!(AO == AtomicOrdering::NotAtomic ||
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1493,6 +1493,17 @@
void emitIfClause(Value *Cond, BodyGenCallbackTy ThenGen,
BodyGenCallbackTy ElseGen, InsertPointTy AllocaIP = {});
+ /// Create a unique global variable to indicate the execution mode of this
+ /// target region. The execution mode is either 'generic', or 'spmd' depending
+ /// on the target directive. This variable is picked up by the offload library
+ /// to setup the device appropriately before kernel launch. If the execution
+ /// mode is 'generic', the runtime reserves one warp for the master,
+ /// otherwise, all warps participate in parallel work.
+ /// \param Name The symbol name associated with the global.
+ /// \param IsSPMDMode is boolean to indicate if the kernel is an SPMD kernel
+ /// or not.
+ GlobalVariable *setPropertyExecutionMode(StringRef Name, bool IsSPMDMode);
+
/// Create the global variable holding the offload mappings information.
GlobalVariable *createOffloadMaptypes(SmallVectorImpl<uint64_t> &Mappings,
std::string VarName);
Index: clang/lib/CodeGen/CodeGenModule.h
===================================================================
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1012,6 +1012,10 @@
return EmittedGlobalBlocks.lookup(BE);
}
+ std::vector<llvm::WeakTrackingVH> &getLLVMCompilerUsed() {
+ return LLVMCompilerUsed;
+ }
+
/// Notes that BE's global block is available via Addr. Asserts that BE
/// isn't already emitted.
void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -833,24 +833,6 @@
IsInTTDRegion = false;
}
-// Create a unique global variable to indicate the execution mode of this target
-// region. The execution mode is either 'generic', or 'spmd' depending on the
-// target directive. This variable is picked up by the offload library to setup
-// the device appropriately before kernel launch. If the execution mode is
-// 'generic', the runtime reserves one warp for the master, otherwise, all
-// warps participate in parallel work.
-static void setPropertyExecutionMode(CodeGenModule &CGM, StringRef Name,
- bool Mode) {
- auto *GVMode = new llvm::GlobalVariable(
- CGM.getModule(), CGM.Int8Ty, /*isConstant=*/true,
- llvm::GlobalValue::WeakAnyLinkage,
- llvm::ConstantInt::get(CGM.Int8Ty, Mode ? OMP_TGT_EXEC_MODE_SPMD
- : OMP_TGT_EXEC_MODE_GENERIC),
- Twine(Name, "_exec_mode"));
- GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
- CGM.addCompilerUsedGlobal(GVMode);
-}
-
void CGOpenMPRuntimeGPU::emitTargetOutlinedFunction(
const OMPExecutableDirective &D, StringRef ParentName,
llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID,
@@ -868,7 +850,10 @@
emitNonSPMDKernel(D, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry,
CodeGen);
- setPropertyExecutionMode(CGM, OutlinedFn->getName(), Mode);
+ llvm::OpenMPIRBuilder &OMPBuilder = getOMPBuilder();
+ llvm::GlobalVariable *GVMode =
+ OMPBuilder.setPropertyExecutionMode(OutlinedFn->getName(), Mode);
+ CGM.addCompilerUsedGlobal(GVMode);
}
CGOpenMPRuntimeGPU::CGOpenMPRuntimeGPU(CodeGenModule &CGM)
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits