|
From: <sv...@va...> - 2006-11-22 11:38:12
|
Author: njn
Date: 2006-11-22 11:38:07 +0000 (Wed, 22 Nov 2006)
New Revision: 6365
Log:
Fix obscure bug in cache simulation, found by Ulrich Drepper.
Modified:
trunk/cachegrind/cg_sim.c
Modified: trunk/cachegrind/cg_sim.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_sim.c 2006-11-22 00:52:00 UTC (rev 6364)
+++ trunk/cachegrind/cg_sim.c 2006-11-22 11:38:07 UTC (rev 6365)
@@ -80,21 +80,6 @@
c->tags[i] =3D 0;
}
=20
-#if 0
-static void print_cache(cache_t2* c)
-{
- UInt set, way, i;
-
- /* Note initialisation and update of 'i'. */
- for (i =3D 0, set =3D 0; set < c->sets; set++) {
- for (way =3D 0; way < c->assoc; way++, i++) {
- VG_(printf)("%16lx ", c->tags[i]);
- }
- VG_(printf)("\n");
- }
-}
-#endif=20
-
/* This is done as a macro rather than by passing in the cache_t2 as an=20
* arg because it slows things down by a small amount (3-5%) due to all=20
* that extra indirection. */
@@ -114,9 +99,10 @@
static __inline__ =
\
void cachesim_##L##_doref(Addr a, UChar size, ULong* m1, ULong *m2) =
\
{ =
\
- register UInt set1 =3D ( a >> L.line_size_bits) & (L.sets_mi=
n_1); \
- register UInt set2 =3D ((a+size-1) >> L.line_size_bits) & (L.sets_mi=
n_1); \
- register UWord tag =3D a >> L.tag_shift; =
\
+ UInt set1 =3D ( a >> L.line_size_bits) & (L.sets_min_1); =
\
+ UInt set2 =3D ((a+size-1) >> L.line_size_bits) & (L.sets_min_1); =
\
+ UWord tag =3D a >> L.tag_shift; =
\
+ UWord tag2; =
\
Int i, j; =
\
Bool is_miss =3D False; =
\
UWord* set; =
\
@@ -176,22 +162,23 @@
is_miss =3D True; =
\
block2: =
\
set =3D &(L.tags[set2 << L.assoc_bits]); =
\
- if (tag =3D=3D set[0]) { =
\
+ tag2 =3D (a+size-1) >> L.tag_shift; =
\
+ if (tag2 =3D=3D set[0]) { =
\
goto miss_treatment; =
\
} =
\
for (i =3D 1; i < L.assoc; i++) { =
\
- if (tag =3D=3D set[i]) { =
\
+ if (tag2 =3D=3D set[i]) { =
\
for (j =3D i; j > 0; j--) { =
\
set[j] =3D set[j - 1]; =
\
} =
\
- set[0] =3D tag; =
\
+ set[0] =3D tag2; =
\
goto miss_treatment; =
\
} =
\
} =
\
for (j =3D L.assoc - 1; j > 0; j--) { =
\
set[j] =3D set[j - 1]; =
\
} =
\
- set[0] =3D tag; =
\
+ set[0] =3D tag2; =
\
is_miss =3D True; =
\
miss_treatment: =
\
if (is_miss) { MISS_TREATMENT; } =
\
|