[llvm] r313831 - [MSan] Disable sanitization for __sanitizer_dtor_callback.

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 15:53:08 PDT 2017


Author: morehouse
Date: Wed Sep 20 15:53:08 2017
New Revision: 313831

URL: http://llvm.org/viewvc/llvm-project?rev=313831&view=rev
Log:
[MSan] Disable sanitization for __sanitizer_dtor_callback.

Summary:
Eliminate unnecessary instrumentation at __sanitizer_dtor_callback
call sites.  Fixes https://github.com/google/sanitizers/issues/861.

Reviewers: eugenis, kcc

Reviewed By: eugenis

Subscribers: vitalybuka, llvm-commits, cfe-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D38063

Added:
    llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
Modified:
    llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=313831&r1=313830&r2=313831&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Wed Sep 20 15:53:08 2017
@@ -2588,6 +2588,7 @@ struct MemorySanitizerVisitor : public I
 
   void visitCallSite(CallSite CS) {
     Instruction &I = *CS.getInstruction();
+    if (I.getMetadata("nosanitize")) return;
     assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
     if (CS.isCall()) {
       CallInst *Call = cast<CallInst>(&I);

Added: llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll?rev=313831&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll (added)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll Wed Sep 20 15:53:08 2017
@@ -0,0 +1,16 @@
+; Verify that calls with !nosanitize are not instrumented by MSan.
+; RUN: opt < %s -msan -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar(i32 %x)
+
+define void @foo() {
+  call void @bar(i32 7), !nosanitize !{}
+  ret void
+}
+
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: store i{{[0-9]+}} 0, {{.*}} @__msan_param_tls
+; CHECK: call void @bar
+; CHECK: ret void




More information about the llvm-commits mailing list