[PATCH] D110468: [AMDGPU] Do not internalize ASan device library functions.
Mahesha S via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 21:50:04 PDT 2021
hsmhsm updated this revision to Diff 375469.
hsmhsm added a comment.
Fix review comments by Praveen and Brian, and rebase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110468/new/
https://reviews.llvm.org/D110468
Files:
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_do_not_internalize.ll
Index: llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_do_not_internalize.ll
===================================================================
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_do_not_internalize.ll
@@ -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
+}
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -517,7 +517,9 @@
/// 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110468.375469.patch
Type: text/x-patch
Size: 2291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/54cb6b5d/attachment.bin>
More information about the llvm-commits
mailing list