[PATCH] D49473: [MSan] run materializeChecks() before materializeStores()

Alexander Potapenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 01:53:48 PDT 2018


glider updated this revision to Diff 156445.
glider retitled this revision from "[MSan] pull insertShadowCheck() into getShadowOriginPtr(). NFC" to "[MSan] run materializeChecks() before materializeStores()".
glider edited the summary of this revision.
glider added a comment.

Updated the patch.


https://reviews.llvm.org/D49473

Files:
  lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -918,9 +918,6 @@
       StoreInst *NewSI = IRB.CreateAlignedStore(Shadow, ShadowPtr, Alignment);
       LLVM_DEBUG(dbgs() << "  STORE: " << *NewSI << "\n");
 
-      if (ClCheckAccessAddress)
-        insertShadowCheck(Addr, NewSI);
-
       if (SI->isAtomic())
         SI->setOrdering(addReleaseOrdering(SI->getOrdering()));
 
@@ -1024,13 +1021,13 @@
                                InstrumentationList.size() + StoreList.size() >
                                    (unsigned)ClInstrumentationWithCallThreshold;
 
-    // Delayed instrumentation of StoreInst.
-    // This may add new checks to be inserted later.
-    materializeStores(InstrumentWithCalls);
-
     // Insert shadow value checks.
     materializeChecks(InstrumentWithCalls);
 
+    // Delayed instrumentation of StoreInst.
+    // This may not add new address checks.
+    materializeStores(InstrumentWithCalls);
+
     return true;
   }
 
@@ -1490,6 +1487,8 @@
   /// Optionally, checks that the store address is fully defined.
   void visitStoreInst(StoreInst &I) {
     StoreList.push_back(&I);
+    if (ClCheckAccessAddress)
+      insertShadowCheck(I.getPointerOperand(), &I);
   }
 
   void handleCASOrRMW(Instruction &I) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49473.156445.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/1430fa54/attachment.bin>


More information about the llvm-commits mailing list