[PATCH] D128320: AMDGPU: Don't crash on global_ctor/dtor declaration
Ruiling, Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 18:03:35 PDT 2022
ruiling updated this revision to Diff 439227.
ruiling added a comment.
address review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128320/new/
https://reviews.llvm.org/D128320
Files:
llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-declaration.ll
Index: llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-declaration.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-declaration.ll
@@ -0,0 +1,8 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 < %s | FileCheck %s
+
+ at llvm.global_ctors = external global [2 x { i32, void ()*, i8* }]
+ at llvm.global_dtors = external global [2 x { i32, void ()*, i8* }]
+
+; No amdgpu_kernels emitted for global_ctors declaration
+; CHECK-NOT: amdgcn.device.init
+; CHECK-NOT: amdgcn.device.fini
Index: llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
@@ -50,7 +50,7 @@
}
bool createInitOrFiniKernel(Module &M, GlobalVariable *GV, bool IsCtor) {
- if (!GV)
+ if (!GV || !GV->hasInitializer())
return false;
ConstantArray *GA = dyn_cast<ConstantArray>(GV->getInitializer());
if (!GA || GA->getNumOperands() == 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128320.439227.patch
Type: text/x-patch
Size: 1079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220623/bc0050cd/attachment.bin>
More information about the llvm-commits
mailing list