From 0e0fe093f2deddabb359fc32a0763cc3acec0544 Mon Sep 17 00:00:00 2001 From: Frederic Crozat <fcrozat@mandriva.com> Date: Thu, 5 Mar 2009 13:53:40 +0100 Subject: [PATCH] cachegrind --- cachegrind/cg_sim.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cachegrind/cg_sim.c b/cachegrind/cg_sim.c index 25bef49..1345211 100644 --- a/cachegrind/cg_sim.c +++ b/cachegrind/cg_sim.c @@ -46,23 +46,27 @@ typedef struct { Int sets_min_1; Int line_size_bits; Int tag_shift; - Char desc_line[128]; UWord* tags; -} cache_t2; + Char desc_line[128]; +} cache_t2 +#ifdef __GNUC__ +__attribute__ ((aligned (8 * sizeof (Int)))) +#endif +; /* By this point, the size/assoc/line_size has been checked. */ static void cachesim_initcache(cache_t config, cache_t2* c) { - Int i; + Int sets; c->size = config.size; c->assoc = config.assoc; c->line_size = config.line_size; - c->sets = (c->size / c->line_size) / c->assoc; - c->sets_min_1 = c->sets - 1; + sets = (c->size / c->line_size) / c->assoc; + c->sets_min_1 = sets - 1; c->line_size_bits = VG_(log2)(c->line_size); - c->tag_shift = c->line_size_bits + VG_(log2)(c->sets); + c->tag_shift = c->line_size_bits + VG_(log2)(sets); if (c->assoc == 1) { VG_(sprintf)(c->desc_line, "%d B, %d B, direct-mapped", @@ -72,11 +76,8 @@ static void cachesim_initcache(cache_t config, cache_t2* c) c->size, c->line_size, c->assoc); } - c->tags = VG_(malloc)("cg.sim.ci.1", - sizeof(UWord) * c->sets * c->assoc); - - for (i = 0; i < c->sets * c->assoc; i++) - c->tags[i] = 0; + c->tags = VG_(calloc)("cg.sim.ci.1", + sizeof(UWord), sets * c->assoc); } /* This is done as a macro rather than by passing in the cache_t2 as an @@ -138,8 +139,7 @@ void cachesim_##L##_doref(Addr a, UChar size, ULong* m1, ULong *m2) \ return; \ \ /* Second case: word straddles two lines. */ \ - /* Nb: this is a fast way of doing ((set1+1) % L.sets) */ \ - } else if (((set1 + 1) & (L.sets-1)) == set2) { \ + } else if (((set1 + 1) & (L.sets_min_1)) == set2) { \ set = &(L.tags[set1 * L.assoc]); \ if (tag == set[0]) { \ goto block2; \ -- 1.6.1.3