1 ; RUN: opt -S -mtriple=amdgcn-- -amdgpu-lower-ctor-dtor < %s | FileCheck %s
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readelf -s - 2>&1 | FileCheck %s -check-prefix=CHECK-VIS
4 @llvm.global_ctors = appending addrspace(1) global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @foo, i8* null }, { i32, void ()*, i8* } { i32 1, void ()* @foo.5, i8* null }]
5 @llvm.global_dtors = appending addrspace(1) global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @bar, i8* null }, { i32, void ()*, i8* } { i32 1, void ()* @bar.5, i8* null }]
7 ; CHECK-LABEL: amdgpu_kernel void @amdgcn.device.init() #0
8 ; CHECK-NEXT: call void @foo
9 ; CHECK-NEXT: call void @foo.5
11 ; CHECK-LABEL: amdgpu_kernel void @amdgcn.device.fini() #1
12 ; CHECK-NEXT: call void @bar
13 ; CHECK-NEXT: call void @bar.5
15 ; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.init
16 ; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.init.kd
17 ; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.fini
18 ; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.fini.kd
20 define internal void @foo() {
24 define internal void @bar() {
28 define internal void @foo.5() {
32 define internal void @bar.5() {
36 ; CHECK: attributes #0 = { "device-init" }
37 ; CHECK: attributes #1 = { "device-fini" }