[PATCH] D149340: [AMDGPU] Place global constructors in .init_array and .fini_array

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 16:11:40 PDT 2023


jhuber6 added a comment.

In D149340#4303678 <https://reviews.llvm.org/D149340#4303678>, @MaskRay wrote:

> I know little about GPU. The generic code emittings constructors to assembly is `AsmPrinter::emitSpecialLLVMGlobal` and `AsmPrinter::emitXXStructorList`. It will use `.init_array`.

This pass currently deletes the global list before making it to the assembly printer, maybe we will get some of this behaviour if we don't do that?

> The priority works this way. Note that in the absence of a `.N` suffix, `.init_array` has the highest priority. https://maskray.me/blog/2021-11-07-init-ctors-init-array
>
>   a.o:(.init_array.1) b.o:(.init_array.1)
>   a.o:(.init_array.2) b.o:(.init_array.2)
>   ...
>   a.o:(.init_array.65533) b.o:(.init_array.65533)
>   a.o:(.init_array.65534) b.o:(.init_array.65534)
>   a.o:(.init_array) b.o:(.init_array)

AMD's linker is `lld` and targets ELF, so it should follow the exact same rules as you are familiar with.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149340/new/

https://reviews.llvm.org/D149340



More information about the llvm-commits mailing list