forked from OSchip/llvm-project
[AMDGPU] Do not internalize ASan device library functions.
ASan device library functions (those starts with the prefix __asan_) are at the moment undergoing through undesired optimizations due to internalization. Hence, in order to avoid such undesired optimizations on ASan device library functions, do not internalize them in the first place. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D110468
This commit is contained in:
parent
fd9a5b911d
commit
c0735cb9f1
|
@ -517,7 +517,9 @@ StringRef AMDGPUTargetMachine::getFeatureString(const Function &F) const {
|
|||
/// Predicate for Internalize pass.
|
||||
static bool mustPreserveGV(const GlobalValue &GV) {
|
||||
if (const Function *F = dyn_cast<Function>(&GV))
|
||||
return F->isDeclaration() || AMDGPU::isEntryFunctionCC(F->getCallingConv());
|
||||
return F->isDeclaration() || F->getName().startswith("__asan_") ||
|
||||
F->getName().startswith("__sanitizer_") ||
|
||||
AMDGPU::isEntryFunctionCC(F->getCallingConv());
|
||||
|
||||
GV.removeDeadConstantUsers();
|
||||
return !GV.use_empty();
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
; RUN: opt -O0 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=OPTNONE %s
|
||||
; RUN: opt -passes='default<O0>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=OPTNONE %s
|
||||
; RUN: opt -O1 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ASAN_NO_INTERNALIZE %s
|
||||
; RUN: opt -passes='default<O1>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ASAN_NO_INTERNALIZE %s
|
||||
|
||||
; OPTNONE: define void @__asan_no_explicit_linkage(
|
||||
; ASAN_NO_INTERNALIZE: define void @__asan_no_explicit_linkage(
|
||||
define void @__asan_no_explicit_linkage() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPTNONE: define weak void @__asan_weak_linkage(
|
||||
; ASAN_NO_INTERNALIZE: define weak void @__asan_weak_linkage(
|
||||
define weak void @__asan_weak_linkage() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPTNONE: define void @__sanitizer_no_explicit_linkage(
|
||||
; ASAN_NO_INTERNALIZE: define void @__sanitizer_no_explicit_linkage(
|
||||
define void @__sanitizer_no_explicit_linkage() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; OPTNONE: define weak void @__sanitizer_weak_linkage(
|
||||
; ASAN_NO_INTERNALIZE: define weak void @__sanitizer_weak_linkage(
|
||||
define weak void @__sanitizer_weak_linkage() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue