Introduced bm_access_*_triggers_conflict() functions.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8189 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c
index 0f0072c..4fb9010 100644
--- a/exp-drd/drd_main.c
+++ b/exp-drd/drd_main.c
@@ -256,8 +256,6 @@
static VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size)
{
- Segment* sg;
-
#if 0
/* The assert below has been commented out because of performance reasons.*/
tl_assert(thread_get_running_tid()
@@ -271,9 +269,7 @@
{
drd_trace_mem_access(addr, size, eLoad);
}
- sg = running_thread_get_segment();
- bm_access_range_load(sg->bm, addr, addr + size);
- if (bm_load_has_conflict_with(thread_get_danger_set(), addr, addr + size))
+ if (bm_access_load_triggers_conflict(addr, addr + size))
{
drd_report_race(addr, size, eLoad);
}
@@ -281,8 +277,6 @@
static VG_REGPARM(1) void drd_trace_load_1(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -290,9 +284,7 @@
{
drd_trace_mem_access(addr, 1, eLoad);
}
- sg = running_thread_get_segment();
- bm_access_load_1(sg->bm, addr);
- if (bm_load_1_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_load_1_triggers_conflict(addr))
{
drd_report_race(addr, 1, eLoad);
}
@@ -300,8 +292,6 @@
static VG_REGPARM(1) void drd_trace_load_2(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -309,9 +299,7 @@
{
drd_trace_mem_access(addr, 2, eLoad);
}
- sg = running_thread_get_segment();
- bm_access_load_2(sg->bm, addr);
- if (bm_load_2_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_load_2_triggers_conflict(addr))
{
drd_report_race(addr, 2, eLoad);
}
@@ -319,8 +307,6 @@
static VG_REGPARM(1) void drd_trace_load_4(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -328,9 +314,7 @@
{
drd_trace_mem_access(addr, 4, eLoad);
}
- sg = running_thread_get_segment();
- bm_access_load_4(sg->bm, addr);
- if (bm_load_4_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_load_4_triggers_conflict(addr))
{
drd_report_race(addr, 4, eLoad);
}
@@ -338,8 +322,6 @@
static VG_REGPARM(1) void drd_trace_load_8(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -347,9 +329,7 @@
{
drd_trace_mem_access(addr, 8, eLoad);
}
- sg = running_thread_get_segment();
- bm_access_load_8(sg->bm, addr);
- if (bm_load_8_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_load_8_triggers_conflict(addr))
{
drd_report_race(addr, 8, eLoad);
}
@@ -358,8 +338,6 @@
static
VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size)
{
- Segment* sg;
-
#if 0
/* The assert below has been commented out because of performance reasons.*/
tl_assert(thread_get_running_tid()
@@ -373,9 +351,7 @@
{
drd_trace_mem_access(addr, size, eStore);
}
- sg = running_thread_get_segment();
- bm_access_range_store(sg->bm, addr, addr + size);
- if (bm_store_has_conflict_with(thread_get_danger_set(), addr, addr + size))
+ if (bm_access_store_triggers_conflict(addr, addr + size))
{
drd_report_race(addr, size, eStore);
}
@@ -383,8 +359,6 @@
static VG_REGPARM(1) void drd_trace_store_1(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -392,9 +366,7 @@
{
drd_trace_mem_access(addr, 1, eStore);
}
- sg = running_thread_get_segment();
- bm_access_store_1(sg->bm, addr);
- if (bm_store_1_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_store_1_triggers_conflict(addr))
{
drd_report_race(addr, 1, eStore);
}
@@ -402,8 +374,6 @@
static VG_REGPARM(1) void drd_trace_store_2(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -411,9 +381,7 @@
{
drd_trace_mem_access(addr, 2, eStore);
}
- sg = running_thread_get_segment();
- bm_access_store_2(sg->bm, addr);
- if (bm_store_2_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_store_2_triggers_conflict(addr))
{
drd_report_race(addr, 2, eStore);
}
@@ -421,8 +389,6 @@
static VG_REGPARM(1) void drd_trace_store_4(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -430,9 +396,7 @@
{
drd_trace_mem_access(addr, 4, eStore);
}
- sg = running_thread_get_segment();
- bm_access_store_4(sg->bm, addr);
- if (bm_store_4_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_store_4_triggers_conflict(addr))
{
drd_report_race(addr, 4, eStore);
}
@@ -440,8 +404,6 @@
static VG_REGPARM(1) void drd_trace_store_8(Addr addr)
{
- Segment* sg;
-
if (! running_thread_is_recording())
return;
@@ -449,9 +411,7 @@
{
drd_trace_mem_access(addr, 8, eStore);
}
- sg = running_thread_get_segment();
- bm_access_store_8(sg->bm, addr);
- if (bm_store_8_has_conflict_with(thread_get_danger_set(), addr))
+ if (bm_access_store_8_triggers_conflict(addr))
{
drd_report_race(addr, 8, eStore);
}
diff --git a/exp-drd/drd_thread.c b/exp-drd/drd_thread.c
index d96db4f..a26f3ed 100644
--- a/exp-drd/drd_thread.c
+++ b/exp-drd/drd_thread.c
@@ -740,6 +740,66 @@
s_danger_set_combine_vc_count++;
}
+Bool bm_access_load_1_triggers_conflict(const Addr a1)
+{
+ bm_access_load_1(running_thread_get_segment()->bm, a1);
+ return bm_load_1_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_load_2_triggers_conflict(const Addr a1)
+{
+ bm_access_load_2(running_thread_get_segment()->bm, a1);
+ return bm_load_2_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_load_4_triggers_conflict(const Addr a1)
+{
+ bm_access_load_4(running_thread_get_segment()->bm, a1);
+ return bm_load_4_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_load_8_triggers_conflict(const Addr a1)
+{
+ bm_access_load_8(running_thread_get_segment()->bm, a1);
+ return bm_load_8_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2)
+{
+ bm_access_range_load(running_thread_get_segment()->bm, a1, a2);
+ return bm_load_has_conflict_with(thread_get_danger_set(), a1, a2);
+}
+
+Bool bm_access_store_1_triggers_conflict(const Addr a1)
+{
+ bm_access_store_1(running_thread_get_segment()->bm, a1);
+ return bm_store_1_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_store_2_triggers_conflict(const Addr a1)
+{
+ bm_access_store_2(running_thread_get_segment()->bm, a1);
+ return bm_store_2_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_store_4_triggers_conflict(const Addr a1)
+{
+ bm_access_store_4(running_thread_get_segment()->bm, a1);
+ return bm_store_4_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_store_8_triggers_conflict(const Addr a1)
+{
+ bm_access_store_8(running_thread_get_segment()->bm, a1);
+ return bm_store_8_has_conflict_with(thread_get_danger_set(), a1);
+}
+
+Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2)
+{
+ bm_access_range_store(running_thread_get_segment()->bm, a1, a2);
+ return bm_store_has_conflict_with(thread_get_danger_set(), a1, a2);
+}
+
/** Call this function whenever a thread is no longer using the memory
* [ a1, a2 [, e.g. because of a call to free() or a stack pointer
* increase.
diff --git a/exp-drd/drd_thread.h b/exp-drd/drd_thread.h
index 914edeb..7a0bd25 100644
--- a/exp-drd/drd_thread.h
+++ b/exp-drd/drd_thread.h
@@ -122,6 +122,18 @@
void thread_get_latest_segment(Segment** sg, const DrdThreadId tid);
void thread_combine_vc(const DrdThreadId joiner, const DrdThreadId joinee);
void thread_combine_vc2(const DrdThreadId tid, const VectorClock* const vc);
+
+Bool bm_access_load_1_triggers_conflict(const Addr a1);
+Bool bm_access_load_2_triggers_conflict(const Addr a1);
+Bool bm_access_load_4_triggers_conflict(const Addr a1);
+Bool bm_access_load_8_triggers_conflict(const Addr a1);
+Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2);
+Bool bm_access_store_1_triggers_conflict(const Addr a1);
+Bool bm_access_store_2_triggers_conflict(const Addr a1);
+Bool bm_access_store_4_triggers_conflict(const Addr a1);
+Bool bm_access_store_8_triggers_conflict(const Addr a1);
+Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2);
+
void thread_stop_using_mem(const Addr a1, const Addr a2);
void thread_start_recording(const DrdThreadId tid);
void thread_stop_recording(const DrdThreadId tid);