From da3a839f90536ad18496a3a023a4d779b92f7ee6 Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Sat, 11 Apr 2015 11:42:22 +0000 Subject: [PATCH] Remove useless arguments in sparsewa, that were inheritated from WordFM These arguments are not needed for sparsewa, as they can only return the key given in input. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15083 --- coregrind/m_sparsewa.c | 6 ++---- helgrind/libhb_core.c | 13 +++++-------- include/pub_tool_sparsewa.h | 16 ++++++---------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/coregrind/m_sparsewa.c b/coregrind/m_sparsewa.c index 94a3cec2dd..3f111c411d 100644 --- a/coregrind/m_sparsewa.c +++ b/coregrind/m_sparsewa.c @@ -274,7 +274,7 @@ void VG_(deleteSWA) ( SparseWA* swa ) Bool VG_(lookupSWA) ( const SparseWA* swa, - /*OUT*/UWord* keyP, /*OUT*/UWord* valP, + /*OUT*/UWord* valP, UWord key ) { Int i; @@ -302,7 +302,6 @@ Bool VG_(lookupSWA) ( const SparseWA* swa, vg_assert(level0->nInUse > 0); ix = key & 0xFF; if (swa_bitarray_read(level0->inUse, ix) == 0) return False; - *keyP = key; /* this is stupid. only here to make it look like WordFM */ *valP = level0->words[ix]; return True; } @@ -366,7 +365,7 @@ Bool VG_(addToSWA) ( SparseWA* swa, UWord key, UWord val ) Bool VG_(delFromSWA) ( SparseWA* swa, - /*OUT*/UWord* oldK, /*OUT*/UWord* oldV, UWord key ) + /*OUT*/UWord* oldV, UWord key ) { Int i; UWord ix; @@ -403,7 +402,6 @@ Bool VG_(delFromSWA) ( SparseWA* swa, if (swa_bitarray_read_then_clear(level0->inUse, ix) == 0) return False; - *oldK = key; /* this is silly */ *oldV = level0->words[ix]; level0->nInUse--; diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c index 1bd771d4be..b9c806480f 100644 --- a/helgrind/libhb_core.c +++ b/helgrind/libhb_core.c @@ -4149,7 +4149,7 @@ static void event_map_bind ( Addr a, SizeT szB, Bool isW, Thr* thr ) OldRef* ref; RCEC* rcec; Word i, j; - UWord keyW, valW; + UWord valW; Bool b; tl_assert(thr); @@ -4173,14 +4173,13 @@ static void event_map_bind ( Addr a, SizeT szB, Bool isW, Thr* thr ) /* Look in the map to see if we already have a record for this address. */ - b = VG_(lookupSWA)( oldrefTree, &keyW, &valW, a ); + b = VG_(lookupSWA)( oldrefTree, &valW, a ); if (b) { /* We already have a record for this address. We now need to see if we have a stack trace pertaining to this (thrid, R/W, size) triple. */ - tl_assert(keyW == a); ref = (OldRef*)valW; tl_assert(ref->magic == OldRef_MAGIC); @@ -4287,7 +4286,7 @@ Bool libhb_event_map_lookup ( /*OUT*/ExeContext** resEC, { Word i, j; OldRef* ref; - UWord keyW, valW; + UWord valW; Bool b; ThrID cand_thrid; @@ -4319,12 +4318,11 @@ Bool libhb_event_map_lookup ( /*OUT*/ExeContext** resEC, cand_a = toCheck[j]; // VG_(printf)("test %ld %p\n", j, cand_a); - b = VG_(lookupSWA)( oldrefTree, &keyW, &valW, cand_a ); + b = VG_(lookupSWA)( oldrefTree, &valW, cand_a ); if (!b) continue; ref = (OldRef*)valW; - tl_assert(keyW == cand_a); tl_assert(ref->magic == OldRef_MAGIC); tl_assert(ref->accs[0].thrid != 0); /* first slot must always be used */ @@ -4705,9 +4703,8 @@ static void event_map_GC ( void ) for (i = 0; i < n2del; i++) { Bool b; Addr ga2del = *(Addr*)VG_(indexXA)( refs2del, i ); - b = VG_(delFromSWA)( oldrefTree, &keyW, &valW, ga2del ); + b = VG_(delFromSWA)( oldrefTree, &valW, ga2del ); tl_assert(b); - tl_assert(keyW == ga2del); oldref = (OldRef*)valW; for (j = 0; j < N_OLDREF_ACCS; j++) { ThrID aThrID = oldref->accs[j].thrid; diff --git a/include/pub_tool_sparsewa.h b/include/pub_tool_sparsewa.h index f56e631c9c..8e1644dd94 100644 --- a/include/pub_tool_sparsewa.h +++ b/include/pub_tool_sparsewa.h @@ -63,21 +63,17 @@ void VG_(deleteSWA) ( SparseWA* swa ); // overwritten. Returned Bool is True iff a previous binding existed. Bool VG_(addToSWA) ( SparseWA* swa, UWord key, UWord val ); -// Delete key from swa, returning associated key and val if found. -// Note: returning associated key is stupid (it can only be the -// key you just specified). This behaviour is retained to make it -// easier to migrate from WordFM. Returned Bool is True iff -// the key was actually bound in the mapping. +// Delete key from swa, returning val if found. +// Returned Bool is True iff the key was actually bound in the mapping. Bool VG_(delFromSWA) ( SparseWA* swa, - /*OUT*/UWord* oldK, /*OUT*/UWord* oldV, + /*OUT*/UWord* oldV, UWord key ); // Indexes swa at 'key' (or, if you like, looks up 'key' in the -// mapping), and returns the associated value, if any, in *valP. For -// compatibility with WordFM, 'key' is also returned in *keyP. Returned -// Bool is True iff a binding for 'key' actually existed. +// mapping), and returns the associated value, if any, in *valP. +// Returned Bool is True iff a binding for 'key' actually existed. Bool VG_(lookupSWA) ( const SparseWA* swa, - /*OUT*/UWord* keyP, /*OUT*/UWord* valP, + /*OUT*/UWord* valP, UWord key ); // Set up 'swa' for iteration. -- 2.47.3