[PATCH] D150675: [AMDGPU] Rewrite device ctor / dtor handling to use .init / .fini sections

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 07:56:26 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, yaxunl, arsenm, rampitec, b-sumner, MaskRay.
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.

Currently, AMDGPU has special handling for constructors and destructors.
We manuall emit a kernel that calls the functoins listed in the global
constructor / destructor list. This currently has two main problems. The
first is that we do not repsect the priortiy and simply call them in any
order. The second is that we redefine the symbol unconditionally which
coulid have a different definition, meaning we cannot merge any code
with a constructor post-codegen. This patch changes the handling to
instead use the standard support for travering the `.init_array` and
`.fini_array` sections the compiler creates. This allows us to emit a
single kernel with `odr` semantics, so even if we emit this multiple
times they will be merged into a single kernel.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150675

Files:
  llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
  llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll
  llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-existing.ll
  llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll
  llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150675.522623.patch
Type: text/x-patch
Size: 18512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230516/d735357d/attachment.bin>


More information about the llvm-commits mailing list