From e3fa3f57bddb555c41ae5f104520629b8569b9f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Thu, 13 Mar 2003 09:01:20 +0000 Subject: [PATCH] Comments... [r879] --- ir/tv/tv.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index bb1c94353..21406852c 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1440,29 +1440,22 @@ entity *get_tv_entity(tarval *tv) { void free_tv_entity(entity *ent) { - /* There can be a tarval referencing this entity. - Even if the tarval is not used by the code any more, - it can still reference an entity. If a hash function - happens to collide with this tarval, we will verify that - it contains a proper entity and we will crash. - As we cannot remove tarvals (they are on an obstack) we - overwrite ent with NULL. */ - /* Get the tarval by allocating a new one. */ - tarval *tv = (tarval *)pset_first(tarvals); + /* There can be a tarval referencing this entity. Even if the + tarval is not used by the code any more, it can still reference + the entity as tarvals live forever (They live on an obstack.). + Further the tarval is hashed into a set. If a hash function + evaluation happens to collide with this tarval, we will vrfy that + it contains a proper entity and we will crash if the entity is + freed. We cannot remove tarvals from the obstack but we can + remove the entry in the hash table. */ tarval *found = NULL; + tarval *tv = (tarval *)pset_first(tarvals); while (tv) { entity *tv_ent = get_tv_entity(tv); - if ((tv_ent) && (tv_ent == ent)) { - found = tv; - //pset_remove(tarvals, tv, tarval_hash(tv)); - //tv->u.P.ent = NULL; - // tv = NULL; - } //else { - tv = pset_next(tarvals); - //} + if ((tv_ent) && (tv_ent == ent)) found = tv; + tv = pset_next(tarvals); } - // pset_break(tarvals); - if (found) { + if (found) pset_remove(tarvals, found, tarval_hash(found)); } } -- 2.20.1