[compiler-rt] r183643 - tsan: more detailed trace for atomic operations (include address and memory ordering)

Dmitry Vyukov dvyukov at google.com
Mon Jun 10 03:01:32 PDT 2013


Author: dvyukov
Date: Mon Jun 10 05:01:31 2013
New Revision: 183643

URL: http://llvm.org/viewvc/llvm-project?rev=183643&view=rev
Log:
tsan: more detailed trace for atomic operations (include address and memory ordering)

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_interface_atomic.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface_atomic.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface_atomic.cc?rev=183643&r1=183642&r2=183643&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface_atomic.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface_atomic.cc Mon Jun 10 05:01:31 2013
@@ -35,18 +35,33 @@ using namespace __tsan;  // NOLINT
     mo = flags()->force_seq_cst_atomics ? (morder)mo_seq_cst : mo; \
     ThreadState *const thr = cur_thread(); \
     AtomicStatInc(thr, sizeof(*a), mo, StatAtomic##func); \
-    ScopedAtomic sa(thr, callpc, __FUNCTION__); \
+    ScopedAtomic sa(thr, callpc, a, mo, __FUNCTION__); \
     return Atomic##func(thr, pc, __VA_ARGS__); \
 /**/
 
+// Some shortcuts.
+typedef __tsan_memory_order morder;
+typedef __tsan_atomic8 a8;
+typedef __tsan_atomic16 a16;
+typedef __tsan_atomic32 a32;
+typedef __tsan_atomic64 a64;
+typedef __tsan_atomic128 a128;
+const morder mo_relaxed = __tsan_memory_order_relaxed;
+const morder mo_consume = __tsan_memory_order_consume;
+const morder mo_acquire = __tsan_memory_order_acquire;
+const morder mo_release = __tsan_memory_order_release;
+const morder mo_acq_rel = __tsan_memory_order_acq_rel;
+const morder mo_seq_cst = __tsan_memory_order_seq_cst;
+
 class ScopedAtomic {
  public:
-  ScopedAtomic(ThreadState *thr, uptr pc, const char *func)
+  ScopedAtomic(ThreadState *thr, uptr pc, const volatile void *a,
+               morder mo, const char *func)
       : thr_(thr) {
     CHECK_EQ(thr_->in_rtl, 0);
     ProcessPendingSignals(thr);
     FuncEntry(thr_, pc);
-    DPrintf("#%d: %s\n", thr_->tid, func);
+    DPrintf("#%d: %s(%p, %d)\n", thr_->tid, func, a, mo);
     thr_->in_rtl++;
   }
   ~ScopedAtomic() {
@@ -58,20 +73,6 @@ class ScopedAtomic {
   ThreadState *thr_;
 };
 
-// Some shortcuts.
-typedef __tsan_memory_order morder;
-typedef __tsan_atomic8 a8;
-typedef __tsan_atomic16 a16;
-typedef __tsan_atomic32 a32;
-typedef __tsan_atomic64 a64;
-typedef __tsan_atomic128 a128;
-const morder mo_relaxed = __tsan_memory_order_relaxed;
-const morder mo_consume = __tsan_memory_order_consume;
-const morder mo_acquire = __tsan_memory_order_acquire;
-const morder mo_release = __tsan_memory_order_release;
-const morder mo_acq_rel = __tsan_memory_order_acq_rel;
-const morder mo_seq_cst = __tsan_memory_order_seq_cst;
-
 static void AtomicStatInc(ThreadState *thr, uptr size, morder mo, StatType t) {
   StatInc(thr, StatAtomic);
   StatInc(thr, t);
@@ -666,7 +667,7 @@ a128 __tsan_atomic64_compare_exchange_va
 #endif
 
 void __tsan_atomic_thread_fence(morder mo) {
-  char* a;
+  char* a = 0;
   SCOPED_ATOMIC(Fence, mo);
 }
 





More information about the llvm-commits mailing list