[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 14:22:01 PDT 2017


morehouse updated this revision to Diff 116072.
morehouse added a comment.

- Add test case.
- Use SanitizerScope.


https://reviews.llvm.org/D38063

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   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);
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===================================================================
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===================================================================
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
              CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope(&CGF);
    // Pass in void pointer and size of region as arguments to runtime
    // function
    llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38063.116072.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170920/6df68d92/attachment.bin>


More information about the llvm-commits mailing list