[AMDGPU] Rewrite device ctor / dtor handling to use .init / .fini sections
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. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D150675
Loading
Please sign in to comment