[llvm-commits] [llvm] r154418 - in /llvm/trunk: lib/Transforms/Instrumentation/ThreadSanitizer.cpp test/Instrumentation/ThreadSanitizer/read_before_write.ll

Nick Lewycky nlewycky at google.com
Sat Apr 28 11:30:17 PDT 2012


On 10 April 2012 11:18, Kostya Serebryany <kcc at google.com> wrote:

> Author: kcc
> Date: Tue Apr 10 13:18:56 2012
> New Revision: 154418
>
> URL: http://llvm.org/viewvc/llvm-project?rev=154418&view=rev
> Log:
> [tsan] compile-time instrumentation: do not instrument a read if
> a write to the same temp follows in the same BB.
> Also add stats printing.
>
> On Spec CPU2006 this optimization saves roughly 4% of instrumented reads
> (which is 3% of all instrumented accesses):
> Writes            : 161216
> Reads             : 446458
> Reads-before-write: 18295
>
>
> Added:
>    llvm/trunk/test/Instrumentation/ThreadSanitizer/read_before_write.ll
> Modified:
>    llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=154418&r1=154417&r2=154418&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Tue Apr
> 10 13:18:56 2012
> @@ -22,6 +22,7 @@
>  #define DEBUG_TYPE "tsan"
>
>  #include "FunctionBlackList.h"
> +#include "llvm/ADT/SmallSet.h"
>  #include "llvm/ADT/SmallString.h"
>  #include "llvm/ADT/SmallVector.h"
>  #include "llvm/ADT/StringExtras.h"
> @@ -45,16 +46,33 @@
>  static cl::opt<std::string>  ClBlackListFile("tsan-blacklist",
>        cl::desc("Blacklist file"), cl::Hidden);
>
> +static cl::opt<bool> ClPrintStats("tsan-print-stats",
> +       cl::desc("Print ThreadSanitizer instrumentation stats"),
> cl::Hidden);
> +
>  namespace {
> +
> +// Stats counters for ThreadSanitizer instrumentation.
> +struct ThreadSanitizerStats {
> +  size_t NumInstrumentedReads;
> +  size_t NumInstrumentedWrites;
> +  size_t NumOmittedReadsBeforeWrite;
> +  size_t NumAccessesWithBadSize;
> +  size_t NumInstrumentedVtableWrites;
> +};
> +
>  /// ThreadSanitizer: instrument the code in module to find races.
>  struct ThreadSanitizer : public FunctionPass {
>   ThreadSanitizer();
>   bool runOnFunction(Function &F);
>   bool doInitialization(Module &M);
> +  bool doFinalization(Module &M);
>   bool instrumentLoadOrStore(Instruction *I);
>   static char ID;  // Pass identification, replacement for typeid.
>
>  private:
> +  void choseInstructionsToInstrument(SmallVectorImpl<Instruction*> &Local,
> +                                     SmallVectorImpl<Instruction*> &All);
>

Typo, "chose" should be "choose".

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120428/839ee75a/attachment.html>


More information about the llvm-commits mailing list