[llvm-commits] [llvm] r168873 - /llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Nov 29 04:30:18 PST 2012


Author: eugenis
Date: Thu Nov 29 06:30:18 2012
New Revision: 168873

URL: http://llvm.org/viewvc/llvm-project?rev=168873&view=rev
Log:
[msan] Make sure that report callbacks do not get merged.

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=168873&r1=168872&r2=168873&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Thu Nov 29 06:30:18 2012
@@ -183,6 +183,8 @@
   MDNode *ColdCallWeights;
   /// \brief The blacklist.
   OwningPtr<BlackList> BL;
+  /// \brief An empty volatile inline asm that prevents callback merge.
+  InlineAsm *EmptyAsm;
 
   friend class MemorySanitizerVisitor;
   friend class VarArgAMD64Helper;
@@ -295,6 +297,11 @@
   OriginTLS = new GlobalVariable(
     M, IRB.getInt32Ty(), false, GlobalVariable::ExternalLinkage, 0,
     "__msan_origin_tls", 0, GlobalVariable::GeneralDynamicTLSModel);
+
+  // We insert an empty inline asm after __msan_report* to avoid callback merge.
+  EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
+                            StringRef(""), StringRef(""),
+                            /*hasSideEffects=*/true);
   return true;
 }
 
@@ -391,6 +398,7 @@
       }
       CallInst *Call = IRB.CreateCall(MS.WarningFn);
       Call->setDebugLoc(OrigIns->getDebugLoc());
+      IRB.CreateCall(MS.EmptyAsm);
       DEBUG(dbgs() << "  CHECK: " << *Cmp << "\n");
     }
     DEBUG(dbgs() << "DONE:\n" << F);





More information about the llvm-commits mailing list