From: Julian Seward Date: Wed, 13 Oct 2004 22:41:16 +0000 (+0000) Subject: Much improve the speed of the dead code elimination pass. X-Git-Tag: svn/VALGRIND_3_0_1^2~1001 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac517a92a924aef2fa5cd590de59b573ca7f37de;p=thirdparty%2Fvalgrind.git Much improve the speed of the dead code elimination pass. git-svn-id: svn://svn.valgrind.org/vex/trunk@333 --- diff --git a/VEX/priv/ir/iropt.c b/VEX/priv/ir/iropt.c index 2b30480751..43f0dacb79 100644 --- a/VEX/priv/ir/iropt.c +++ b/VEX/priv/ir/iropt.c @@ -821,12 +821,13 @@ static IRBB* cprop_BB ( IRBB* in ) -- really just operating a set or IRTemps. */ -static void addUses_Temp ( Hash64* set, IRTemp tmp ) +inline +static void addUses_Temp ( Bool* set, IRTemp tmp ) { - addToH64(set, (ULong)tmp, 0); + set[(Int)tmp] = True; } -static void addUses_Expr ( Hash64* set, IRExpr* e ) +static void addUses_Expr ( Bool* set, IRExpr* e ) { Int i; switch (e->tag) { @@ -865,7 +866,7 @@ static void addUses_Expr ( Hash64* set, IRExpr* e ) } } -static void addUses_Stmt ( Hash64* set, IRStmt* st ) +static void addUses_Stmt ( Bool* set, IRStmt* st ) { Int i; IRDirty* d; @@ -898,7 +899,7 @@ static void addUses_Stmt ( Hash64* set, IRStmt* st ) vex_printf("\n"); ppIRStmt(st); vpanic("addUses_Stmt"); - } + } } @@ -913,9 +914,13 @@ static void addUses_Stmt ( Hash64* set, IRStmt* st ) static void dead_BB ( IRBB* bb ) { Int i; - Hash64* set = newH64(); + Int n_tmps = bb->tyenv->types_used; + Bool* set = LibVEX_Alloc(n_tmps * sizeof(Bool)); IRStmt* st; + for (i = 0; i < n_tmps; i++) + set[i] = False; + /* start off by recording IRTemp uses in the next field. */ addUses_Expr(set, bb->next); @@ -925,7 +930,7 @@ static void dead_BB ( IRBB* bb ) if (!st) continue; if (st->tag == Ist_Tmp - && !lookupH64(set, NULL, (ULong)(st->Ist.Tmp.tmp))) { + && set[(Int)(st->Ist.Tmp.tmp)] == False) { /* it's an IRTemp which never got used. Delete it. */ if (DEBUG_IROPT) { vex_printf("DEAD: ");