summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-09-14 17:18:37 +0000
committerEtienne Bergeron <etienneb@google.com>2016-09-14 17:18:37 +0000
commit752f8839a4eb3d00a8f788c15a4732484e9a957d (patch)
tree0a9debdfcd21ce14d08105b9578f3f5b91ff944e /llvm/lib
parenta369219ce676ae960046ef00d6d23be2d10701ee (diff)
downloadbcm5719-llvm-752f8839a4eb3d00a8f788c15a4732484e9a957d.tar.gz
bcm5719-llvm-752f8839a4eb3d00a8f788c15a4732484e9a957d.zip
[compiler-rt] Avoid instrumenting sanitizer functions
Summary: Function __asan_default_options is called by __asan_init before the shadow memory got initialized. Instrumenting that function may lead to flaky execution. As the __asan_default_options is provided by users, we cannot expect them to add the appropriate function atttributes to avoid instrumentation. Reviewers: kcc, rnk Subscribers: dberris, chrisha, llvm-commits Differential Revision: https://reviews.llvm.org/D24566 llvm-svn: 281503
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index a5972d45993..df180df7dea 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1882,17 +1882,21 @@ void AddressSanitizer::markEscapedLocalAllocas(Function &F) {
bool AddressSanitizer::runOnFunction(Function &F) {
if (&F == AsanCtorFunction) return false;
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
- DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
- initializeCallbacks(*F.getParent());
-
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
+ if (F.getName().find("__asan_") != std::string::npos) return false;
// If needed, insert __asan_init before checking for SanitizeAddress attr.
+ // This function needs to be called even if the function body is not
+ // instrumented.
maybeInsertAsanInitAtFunctionEntry(F);
-
+
+ // Leave if the function doesn't need instrumentation.
if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return false;
- if (!ClDebugFunc.empty() && ClDebugFunc != F.getName()) return false;
+ DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
+
+ initializeCallbacks(*F.getParent());
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
FunctionStateRAII CleanupObj(this);
OpenPOWER on IntegriCloud