[AMDGPU] Change ASAN init/fini kernels linkage to external.

HSA runtime fails to find the symbols for Init and Fini kernels as
they mark with internal linkage, changing the linkage to external
to fix those errors.

Differential Revision: https://reviews.llvm.org/D110054
This commit is contained in:
Praveen Velliengiri 2021-09-27 11:49:49 -06:00 committed by Anshil Gandhi
parent b2af2aeea6
commit e90b512c4d
3 changed files with 14 additions and 2 deletions

View File

@ -36,7 +36,7 @@ public:
Function *InitOrFiniKernel = Function::createWithDefaultAttr(
FunctionType::get(Type::getVoidTy(M.getContext()), false),
GlobalValue::InternalLinkage, 0, InitOrFiniKernelName, &M);
GlobalValue::ExternalLinkage, 0, InitOrFiniKernelName, &M);
BasicBlock *InitOrFiniKernelBB =
BasicBlock::Create(M.getContext(), "", InitOrFiniKernel);
ReturnInst::Create(M.getContext(), InitOrFiniKernelBB);

View File

@ -1,4 +1,5 @@
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-lower-ctor-dtor < %s | FileCheck %s
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readelf -s - 2>&1 | FileCheck %s -check-prefix=CHECK-VIS
@llvm.global_ctors = appending addrspace(1) global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @foo, i8* null }]
@llvm.global_dtors = appending addrspace(1) global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @bar, i8* null }]
@ -9,6 +10,11 @@
; CHECK-LABEL: amdgpu_kernel void @amdgcn.device.fini() #1
; CHECK-NEXT: call void @bar
; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.init
; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.init.kd
; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.fini
; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.fini.kd
define internal void @foo() {
ret void
}

View File

@ -1,4 +1,5 @@
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-lower-ctor-dtor < %s | FileCheck %s
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -filetype=obj -o - < %s | llvm-readelf -s - 2>&1 | FileCheck %s -check-prefix=CHECK-VIS
@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 }]
@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 }]
@ -11,6 +12,11 @@
; CHECK-NEXT: call void @bar
; CHECK-NEXT: call void @bar.5
; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.init
; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.init.kd
; CHECK-VIS: FUNC GLOBAL PROTECTED {{.*}} amdgcn.device.fini
; CHECK-VIS: OBJECT GLOBAL DEFAULT {{.*}} amdgcn.device.fini.kd
define internal void @foo() {
ret void
}
@ -28,4 +34,4 @@ define internal void @bar.5() {
}
; CHECK: attributes #0 = { "device-init" }
; CHECK: attributes #1 = { "device-fini" }
; CHECK: attributes #1 = { "device-fini" }