[llvm] 94f73fd - AMDGPU: Code simplification for ctor/dtor lowering
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 12:39:55 PST 2022
Author: Matt Arsenault
Date: 2022-11-28T15:39:50-05:00
New Revision: 94f73fd6f834b3c67dc29249f54931c54dbe14c7
URL: https://github.com/llvm/llvm-project/commit/94f73fd6f834b3c67dc29249f54931c54dbe14c7
DIFF: https://github.com/llvm/llvm-project/commit/94f73fd6f834b3c67dc29249f54931c54dbe14c7.diff
LOG: AMDGPU: Code simplification for ctor/dtor lowering
Move the shared global variable lookup into the function.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
index 8fcf669041b98..40476ce138d29 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
@@ -49,7 +49,8 @@ class AMDGPUCtorDtorLowering final : public ModulePass {
return InitOrFiniKernel;
}
- bool createInitOrFiniKernel(Module &M, GlobalVariable *GV, bool IsCtor) {
+ bool createInitOrFiniKernel(Module &M, StringRef GlobalName, bool IsCtor) {
+ GlobalVariable *GV = M.getGlobalVariable(GlobalName);
if (!GV || !GV->hasInitializer())
return false;
ConstantArray *GA = dyn_cast<ConstantArray>(GV->getInitializer());
@@ -85,11 +86,7 @@ ModulePass *llvm::createAMDGPUCtorDtorLoweringPass() {
bool AMDGPUCtorDtorLowering::runOnModule(Module &M) {
bool Modified = false;
- Modified |=
- createInitOrFiniKernel(M, M.getGlobalVariable("llvm.global_ctors"),
- /*IsCtor =*/true);
- Modified |=
- createInitOrFiniKernel(M, M.getGlobalVariable("llvm.global_dtors"),
- /*IsCtor =*/false);
+ Modified |= createInitOrFiniKernel(M, "llvm.global_ctors", /*IsCtor =*/true);
+ Modified |= createInitOrFiniKernel(M, "llvm.global_dtors", /*IsCtor =*/false);
return Modified;
}
More information about the llvm-commits
mailing list