<br><br><div class="gmail_quote">On 10 April 2012 11:18, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Author: kcc<br>
Date: Tue Apr 10 13:18:56 2012<br>
New Revision: 154418<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=154418&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=154418&view=rev</a><br>
Log:<br>
[tsan] compile-time instrumentation: do not instrument a read if<br>
a write to the same temp follows in the same BB.<br>
Also add stats printing.<br>
<br>
On Spec CPU2006 this optimization saves roughly 4% of instrumented reads<br>
(which is 3% of all instrumented accesses):<br>
Writes            : 161216<br>
Reads             : 446458<br>
Reads-before-write: 18295<br>
<br>
<br>
Added:<br>
    llvm/trunk/test/Instrumentation/ThreadSanitizer/read_before_write.ll<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=154418&r1=154417&r2=154418&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=154418&r1=154417&r2=154418&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Tue Apr 10 13:18:56 2012<br>
@@ -22,6 +22,7 @@<br>
 #define DEBUG_TYPE "tsan"<br>
<br>
 #include "FunctionBlackList.h"<br>
+#include "llvm/ADT/SmallSet.h"<br>
 #include "llvm/ADT/SmallString.h"<br>
 #include "llvm/ADT/SmallVector.h"<br>
 #include "llvm/ADT/StringExtras.h"<br>
@@ -45,16 +46,33 @@<br>
 static cl::opt<std::string>  ClBlackListFile("tsan-blacklist",<br>
        cl::desc("Blacklist file"), cl::Hidden);<br>
<br>
+static cl::opt<bool> ClPrintStats("tsan-print-stats",<br>
+       cl::desc("Print ThreadSanitizer instrumentation stats"), cl::Hidden);<br>
+<br>
 namespace {<br>
+<br>
+// Stats counters for ThreadSanitizer instrumentation.<br>
+struct ThreadSanitizerStats {<br>
+  size_t NumInstrumentedReads;<br>
+  size_t NumInstrumentedWrites;<br>
+  size_t NumOmittedReadsBeforeWrite;<br>
+  size_t NumAccessesWithBadSize;<br>
+  size_t NumInstrumentedVtableWrites;<br>
+};<br>
+<br>
 /// ThreadSanitizer: instrument the code in module to find races.<br>
 struct ThreadSanitizer : public FunctionPass {<br>
   ThreadSanitizer();<br>
   bool runOnFunction(Function &F);<br>
   bool doInitialization(Module &M);<br>
+  bool doFinalization(Module &M);<br>
   bool instrumentLoadOrStore(Instruction *I);<br>
   static char ID;  // Pass identification, replacement for typeid.<br>
<br>
  private:<br>
+  void choseInstructionsToInstrument(SmallVectorImpl<Instruction*> &Local,<br>
+                                     SmallVectorImpl<Instruction*> &All);<br></blockquote><div><br></div><div>Typo, "chose" should be "choose".</div><div><br></div><div>Nick</div><div><br></div>

</div>