Move setPropertyExecutionMode() from Clang to OpenMPIRBuilder and change the references in Clang to use the function from OMPIRBuilder.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Not an expert here, only some minor comments.
clang/lib/CodeGen/CodeGenModule.h | ||
---|---|---|
1015 | Return a reference instead of pointer here? | |
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
1506 | Rename to sth like isSPMDMode or so? To me Mode reads overly general. | |
1507 | Should this preferably be a reference instead of pointer? |
clang/lib/CodeGen/CodeGenModule.h | ||
---|---|---|
1016 | I believe that this can be simplified to std::vector<llvm::WeakTrackingVH> &getLLVMCompilerUsed() { return LLVMCompilerUsed; } | |
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
1509 | ...., bool IsSPMDMode, std::vector<llvm::WeakTrackingVH> &LLVMCompilerUsed); | |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
4938 | ...., std::vector<llvm::WeakTrackingVH> &LLVMCompilerUsed) {` | |
4947 | Can this assertion ever be not be met? I'm just curious, given that you create that GVMode yourself. |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
4947 | Adopted this assert from Clang Codegen addCompilerUsedGlobal() which is called inside setPropertyExecutionMode() in CGOpenMPRuntimeGPU.cpp Actual definition of addCompilerusedGlobal() in CodeGenModule.cpp void CodeGenModule::addCompilerUsedGlobal(llvm::GlobalValue *GV) { assert(!GV->isDeclaration() && "Only globals with definition can force usage."); LLVMCompilerUsed.emplace_back(GV); } |
Mostly nits. One problem I have is the vector. I do not believe Flang will use the same for their "llvm.used" tracking. I think it makes more sense to provide a callback or just return the global and let the caller handle it.
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
---|---|---|
1508 | ||
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
4937 | ||
4950 | No llvm:: here. |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
4950 | Sorry, Can you please elaborate which llvm:: you mentioned about here? Thanks! |
Addressed review comments by making setPropertyExecutionMode() to return a Global Value instead of void. Rebased patch.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
4947 | Sorry for the confusion I potentially created: I mainly wanted to understand if that case can ever happen. |
setPropertyExecutionMode function is no longer present / used in clang because of a change in https://reviews.llvm.org/D142569 So abandoning this patch to migrate that function into OMPIRBuilder.
Return a reference instead of pointer here?