Jakub Jelinek 76c2ba
--- valgrind-3.4.0/cachegrind/cg_sim.c.jj	2007-01-08 02:43:10.000000000 -0500
Jakub Jelinek 76c2ba
+++ valgrind-3.4.0/cachegrind/cg_sim.c	2007-02-13 07:15:46.000000000 -0500
Jakub Jelinek 7657d9
@@ -42,27 +42,30 @@ typedef struct {
Jakub Jelinek 8f5f0f
    Int          size;                   /* bytes */
Jakub Jelinek 8f5f0f
    Int          assoc;
Jakub Jelinek 8f5f0f
    Int          line_size;              /* bytes */
Jakub Jelinek 8f5f0f
-   Int          sets;
Jakub Jelinek 8f5f0f
    Int          sets_min_1;
Jakub Jelinek 8f5f0f
    Int          line_size_bits;
Jakub Jelinek 8f5f0f
    Int          tag_shift;
Jakub Jelinek 8f5f0f
-   Char         desc_line[128];
Jakub Jelinek 8f5f0f
    UWord*       tags;
Jakub Jelinek 8f5f0f
-} cache_t2;
Jakub Jelinek 8f5f0f
+   Char         desc_line[128];
Jakub Jelinek 8f5f0f
+} cache_t2
Jakub Jelinek 8f5f0f
+#ifdef __GNUC__
Jakub Jelinek 8f5f0f
+__attribute__ ((aligned (8 * sizeof (Int))))
Jakub Jelinek 8f5f0f
+#endif
Jakub Jelinek 8f5f0f
+;
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 8f5f0f
 /* By this point, the size/assoc/line_size has been checked. */
Jakub Jelinek 8f5f0f
 static void cachesim_initcache(cache_t config, cache_t2* c)
Jakub Jelinek 8f5f0f
 {
Jakub Jelinek 8f5f0f
-   Int i;
Jakub Jelinek 8f5f0f
+   Int sets;
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 8f5f0f
    c->size      = config.size;
Jakub Jelinek 8f5f0f
    c->assoc     = config.assoc;
Jakub Jelinek 8f5f0f
    c->line_size = config.line_size;
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 8f5f0f
-   c->sets           = (c->size / c->line_size) / c->assoc;
Jakub Jelinek 8f5f0f
-   c->sets_min_1     = c->sets - 1;
Jakub Jelinek 8f5f0f
+   sets              = (c->size / c->line_size) / c->assoc;
Jakub Jelinek 8f5f0f
+   c->sets_min_1     = sets - 1;
Jakub Jelinek 8f5f0f
    c->line_size_bits = VG_(log2)(c->line_size);
Jakub Jelinek 8f5f0f
-   c->tag_shift      = c->line_size_bits + VG_(log2)(c->sets);
Jakub Jelinek 8f5f0f
+   c->tag_shift      = c->line_size_bits + VG_(log2)(sets);
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 8f5f0f
    if (c->assoc == 1) {
Jakub Jelinek 8f5f0f
       VG_(sprintf)(c->desc_line, "%d B, %d B, direct-mapped", 
Jakub Jelinek 7657d9
@@ -72,11 +75,8 @@ static void cachesim_initcache(cache_t c
Jakub Jelinek 8f5f0f
                                  c->size, c->line_size, c->assoc);
Jakub Jelinek 8f5f0f
    }
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 76c2ba
-   c->tags = VG_(malloc)("cg.sim.ci.1",
Jakub Jelinek 76c2ba
-                         sizeof(UWord) * c->sets * c->assoc);
Jakub Jelinek 8f5f0f
-
Jakub Jelinek 8f5f0f
-   for (i = 0; i < c->sets * c->assoc; i++)
Jakub Jelinek 8f5f0f
-      c->tags[i] = 0;
Jakub Jelinek 76c2ba
+   c->tags = VG_(calloc)("cg.sim.ci.1",
Jakub Jelinek 0a98d2
+                         sizeof(UWord), sets * c->assoc);
Jakub Jelinek 8f5f0f
 }
Jakub Jelinek 8f5f0f
 
Jakub Jelinek 8f5f0f
 /* This is done as a macro rather than by passing in the cache_t2 as an 
Jakub Jelinek 7657d9
@@ -138,8 +138,7 @@ void cachesim_##L##_doref(Addr a, UChar 
Jakub Jelinek 8f5f0f
       return;                                                               \
Jakub Jelinek 8f5f0f
                                                                             \
Jakub Jelinek 8f5f0f
    /* Second case: word straddles two lines. */                             \
Jakub Jelinek 8f5f0f
-   /* Nb: this is a fast way of doing ((set1+1) % L.sets) */                \
Jakub Jelinek 8f5f0f
-   } else if (((set1 + 1) & (L.sets-1)) == set2) {                          \
Jakub Jelinek 8f5f0f
+   } else if (((set1 + 1) & (L.sets_min_1)) == set2) {                      \
Jakub Jelinek 7657d9
       set = &(L.tags[set1 * L.assoc]);                                      \
Jakub Jelinek 8f5f0f
       if (tag == set[0]) {                                                  \
Jakub Jelinek 8f5f0f
          goto block2;                                                       \