[AMDGPU] Handle functions in llvm's global ctors and dtors list
authorReshabh Sharma <Reshabhkumar.Sharma@amd.com>
Fri, 6 Aug 2021 09:56:12 +0000 (15:26 +0530)
committerReshabh Sharma <Reshabhkumar.Sharma@amd.com>
Fri, 6 Aug 2021 10:23:33 +0000 (15:53 +0530)
commit5173854f1994a8cbeb1da0ca074e8f9bcff2be92
tree1a36dcce6ba2778f38a0356afaef6601fd7a274d
parentdbce6a8d9d7c78e6aee989db8a9f29ad8b7cf0a7
[AMDGPU] Handle functions in llvm's global ctors and dtors list

This patch introduces a new code object metadata field, ".kind"
which is used to add support for init and fini kernels.

HSAStreamer will use function attributes, "device-init" and
"device-fini" to distinguish between init and fini kernels from
the regular kernels and will emit metadata with ".kind" set to
"init" and "fini" respectively.

To reduce the number of init and fini kernels, the ctors and
dtors present in the llvm's global.ctors and global.dtors lists
are called from a single init and fini kernel respectively.

Reviewed by: yaxunl

Differential Revision: https://reviews.llvm.org/D105682
llvm/docs/AMDGPUUsage.rst
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp [new file with mode: 0644]
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/CMakeLists.txt
llvm/test/CodeGen/AMDGPU/hsa-metadata-from-llvm-ctor-dtor-list.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/AMDGPU/BUILD.gn