[PATCH] D151153: [AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 22 13:52:04 PDT 2023
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, yaxunl, arsenm, rampitec.
Herald added subscribers: foad, kerbowa, hiraditya, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
We only expect these ctor / dtor functions to be called with a single
thread. Add the appropriate attributes to indicate this to the backend.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151153
Files:
llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll
llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll
llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll
Index: llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll
+++ llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll
@@ -57,5 +57,5 @@
ret void
}
-; CHECK: attributes #0 = { "device-init" }
-; CHECK: attributes #1 = { "device-fini" }
+; CHECK: attributes #0 = { "amdgpu-flat-work-group-size"="1,1" "device-init" }
+; CHECK: attributes #1 = { "amdgpu-flat-work-group-size"="1,1" "device-fini" }
Index: llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll
+++ llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll
@@ -58,5 +58,5 @@
ret void
}
-; CHECK: attributes #0 = { "device-init" }
-; CHECK: attributes #1 = { "device-fini" }
+; CHECK: attributes #0 = { "amdgpu-flat-work-group-size"="1,1" "device-init" }
+; CHECK: attributes #1 = { "amdgpu-flat-work-group-size"="1,1" "device-fini" }
Index: llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll
+++ llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll
@@ -64,5 +64,5 @@
; CHECK: while.end:
; CHECK-NEXT: ret void
-; CHECK: attributes #[[ATTR0:[0-9]+]] = { "device-init" }
-; CHECK: attributes #[[ATTR1:[0-9]+]] = { "device-fini" }
+; CHECK: attributes #[[ATTR0:[0-9]+]] = { "amdgpu-flat-work-group-size"="1,1" "device-init" }
+; CHECK: attributes #[[ATTR1:[0-9]+]] = { "amdgpu-flat-work-group-size"="1,1" "device-fini" }
Index: llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
@@ -38,6 +38,7 @@
FunctionType::get(Type::getVoidTy(M.getContext()), false),
GlobalValue::WeakODRLinkage, 0, InitOrFiniKernelName, &M);
InitOrFiniKernel->setCallingConv(CallingConv::AMDGPU_KERNEL);
+ InitOrFiniKernel->addFnAttr("amdgpu-flat-work-group-size", "1,1");
if (IsCtor)
InitOrFiniKernel->addFnAttr("device-init");
else
@@ -58,6 +59,7 @@
// void call_init_array_callbacks() {
// for (auto start = __init_array_start; start != __init_array_end; ++start)
// reinterpret_cast<InitCallback *>(*start)();
+// }
static void createInitOrFiniCalls(Function &F, bool IsCtor) {
Module &M = *F.getParent();
LLVMContext &C = M.getContext();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151153.524473.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/5e8b5e51/attachment.bin>
More information about the llvm-commits
mailing list