[tsan] disable load widening in ThreadSanitizer mode
[oota-llvm.git] / lib / Analysis / MemoryDependenceAnalysis.cpp
index 5cb001688552d9842789f4d8c90a3df023b2f3c9..9a1edc763f18f62302ceab86eb37aa9cacf323e6 100644 (file)
@@ -283,6 +283,12 @@ getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs,
                                 const DataLayout &TD) {
   // We can only extend simple integer loads.
   if (!isa<IntegerType>(LI->getType()) || !LI->isSimple()) return 0;
+
+  // Load widening is hostile to ThreadSanitizer: it may cause false positives
+  // or make the reports more cryptic (access sizes are wrong).
+  if (LI->getParent()->getParent()->getAttributes().
+      hasAttribute(AttributeSet::FunctionIndex, Attribute::ThreadSafety))
+    return 0;
   
   // Get the base of this load.
   int64_t LIOffs = 0;