[asan] Disabling speculative loads under asan. Patch by Mike Aizatsky
[oota-llvm.git] / lib / Analysis / ValueTracking.cpp
index 2a93e0d64d622078260bdf27b4d225abffd6e2a2..5caffee8fe73ba7729737c1c4e2c3b485adebb15 100644 (file)
@@ -3187,7 +3187,11 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
     const LoadInst *LI = cast<LoadInst>(Inst);
     if (!LI->isUnordered() ||
         // Speculative load may create a race that did not exist in the source.
-        LI->getParent()->getParent()->hasFnAttribute(Attribute::SanitizeThread))
+        LI->getParent()->getParent()->hasFnAttribute(
+            Attribute::SanitizeThread) ||
+        // Speculative load may load data from dirty regions.
+        LI->getParent()->getParent()->hasFnAttribute(
+            Attribute::SanitizeAddress))
       return false;
     const DataLayout &DL = LI->getModule()->getDataLayout();
     return isDereferenceableAndAlignedPointer(