[PATCH] D21541: [asan] Do not instrument accesses to profiling globals
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 10:38:05 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273444: [asan] Do not instrument accesses to profiling globals (authored by vedantk).
Changed prior to commit:
http://reviews.llvm.org/D21541?vs=61327&id=61571#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21541
Files:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-profiling-globals.ll
Index: llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-profiling-globals.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-profiling-globals.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-profiling-globals.ll
@@ -0,0 +1,9 @@
+; This test checks that we don't instrument globals created by profiling passes.
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s
+
+ at __profc_test = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
+ at __llvm_gcov_ctr = internal global [1 x i64] zeroinitializer
+
+; CHECK-DAG: @asan.module_ctor
+; CHECK-NOT: @__asan_gen{{.*}}__llvm_gcov_ctr
+; CHECK-NOT: @__asan_gen{{.*}}__profc_test
Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -857,10 +857,19 @@
return GV;
}
-static bool GlobalWasGeneratedByAsan(GlobalVariable *G) {
- return G->getName().startswith(kAsanGenPrefix) ||
- G->getName().startswith(kSanCovGenPrefix) ||
- G->getName().startswith(kODRGenPrefix);
+/// \brief Check if \p G has been created by a trusted compiler pass.
+static bool GlobalWasGeneratedByCompiler(GlobalVariable *G) {
+ // Do not instrument asan globals.
+ if (G->getName().startswith(kAsanGenPrefix) ||
+ G->getName().startswith(kSanCovGenPrefix) ||
+ G->getName().startswith(kODRGenPrefix))
+ return true;
+
+ // Do not instrument gcov counter arrays.
+ if (G->getName() == "__llvm_gcov_ctr")
+ return true;
+
+ return false;
}
Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB) {
@@ -1243,7 +1252,7 @@
if (GlobalsMD.get(G).IsBlacklisted) return false;
if (!Ty->isSized()) return false;
if (!G->hasInitializer()) return false;
- if (GlobalWasGeneratedByAsan(G)) return false; // Our own global.
+ if (GlobalWasGeneratedByCompiler(G)) return false; // Our own globals.
// Touch only those globals that will not be defined in other modules.
// Don't handle ODR linkage types and COMDATs since other modules may be built
// without ASan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21541.61571.patch
Type: text/x-patch
Size: 2337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160622/a86125b0/attachment.bin>
More information about the llvm-commits
mailing list