[compiler-rt] r183418 - tsan: use memory access size for Go after all

Kostya Serebryany kcc at google.com
Fri Jun 7 00:02:14 PDT 2013


On Thu, Jun 6, 2013 at 6:31 PM, Dmitry Vyukov <dvyukov at google.com> wrote:

> Author: dvyukov
> Date: Thu Jun  6 09:31:15 2013
> New Revision: 183418
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183418&view=rev
> Log:
> tsan: use memory access size for Go after all
> helps to make range access functions correct and fast
>

Wow! Really?
I like the change very much, but I am very curious why it makes things
faster.

--kcc


>
> Modified:
>     compiler-rt/trunk/lib/tsan/go/tsan_go.cc
>     compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
>     compiler-rt/trunk/lib/tsan/rtl/tsan_update_shadow_word_inl.h
>
> Modified: compiler-rt/trunk/lib/tsan/go/tsan_go.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/tsan_go.cc?rev=183418&r1=183417&r2=183418&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
> +++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Thu Jun  6 09:31:15 2013
> @@ -116,12 +116,14 @@ void __tsan_write(ThreadState *thr, void
>
>  void __tsan_read_range(ThreadState *thr, void *addr, uptr size, uptr step,
>                         void *pc) {
> -  MemoryAccessRangeStep(thr, (uptr)pc, (uptr)addr, size, step, false);
> +  (void)step;
> +  MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, false);
>  }
>
>  void __tsan_write_range(ThreadState *thr, void *addr, uptr size, uptr
> step,
>                          void *pc) {
> -  MemoryAccessRangeStep(thr, (uptr)pc, (uptr)addr, size, step, true);
> +  (void)step;
> +  MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, true);
>  }
>
>  void __tsan_func_enter(ThreadState *thr, void *pc) {
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=183418&r1=183417&r2=183418&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Thu Jun  6 09:31:15
> 2013
> @@ -374,25 +374,4 @@ void MemoryAccessRange(ThreadState *thr,
>    }
>  }
>
> -void MemoryAccessRangeStep(ThreadState *thr, uptr pc, uptr addr,
> -    uptr size, uptr step, bool is_write) {
> -  if (size == 0)
> -    return;
> -  FastState fast_state = thr->fast_state;
> -  if (fast_state.GetIgnoreBit())
> -    return;
> -  StatInc(thr, StatMopRange);
> -  fast_state.IncrementEpoch();
> -  thr->fast_state = fast_state;
> -  TraceAddEvent(thr, fast_state, EventTypeMop, pc);
> -
> -  for (uptr addr_end = addr + size; addr < addr_end; addr += step) {
> -    u64 *shadow_mem = (u64*)MemToShadow(addr);
> -    Shadow cur(fast_state);
> -    cur.SetWrite(is_write);
> -    cur.SetAddr0AndSizeLog(addr & (kShadowCell - 1), kSizeLog1);
> -    MemoryAccessImpl(thr, addr, kSizeLog1, is_write, false,
> -        shadow_mem, cur);
> -  }
> -}
>  }  // namespace __tsan
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_update_shadow_word_inl.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_update_shadow_word_inl.h?rev=183418&r1=183417&r2=183418&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_update_shadow_word_inl.h (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_update_shadow_word_inl.h Thu Jun
>  6 09:31:15 2013
> @@ -57,8 +57,7 @@ do {
>      goto RACE;
>    }
>    // Do the memory access intersect?
> -  // In Go all memory accesses are 1 byte, so there can be no
> intersections.
> -  if (kCppMode && Shadow::TwoRangesIntersect(old, cur, kAccessSize)) {
> +  if (Shadow::TwoRangesIntersect(old, cur, kAccessSize)) {
>      StatInc(thr, StatShadowIntersect);
>      if (Shadow::TidsAreEqual(old, cur)) {
>        StatInc(thr, StatShadowSameThread);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130607/f79411fe/attachment.html>


More information about the llvm-commits mailing list