@@ -157,6 +157,8 @@ const char *show_pseudo(pseudo_t pseudo)
break;
case PSEUDO_UNDEF:
return "UNDEF";
+ case PSEUDO_INDIR:
+ return show_pseudo(pseudo->target);
default:
snprintf(buf, 64, "<bad pseudo type %d>", pseudo->type);
}
@@ -29,6 +29,7 @@ enum pseudo_type {
PSEUDO_VAL,
PSEUDO_ARG,
PSEUDO_PHI,
+ PSEUDO_INDIR,
};
struct pseudo {
@@ -40,6 +41,7 @@ struct pseudo {
struct symbol *sym;
struct instruction *def;
long long value;
+ pseudo_t target;
};
void *priv;
};
@@ -73,6 +73,8 @@ pseudo_t load_var(struct basic_block *bb, struct symbol *var)
pseudo_t val = phi_map_lookup(var->phi_map, bb);
if (!val)
val = load_var_parents(bb, var);
+ while (val->type == PSEUDO_INDIR)
+ val = val->target;
return val;
}
Simplification of trivial pseudos require to replace a pseudo for another in all ptrmap. Since this could be an annoying and relatively costly operation if effectively done by looking after each pseudos, this patch introduce a new type of pseudo used as a a sort of a symlink for another one: PSEUDO_INDIR. So the processing is almost for free and this indirection has just to be done when looking after the corresponding var. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- linearize.c | 2 ++ linearize.h | 2 ++ ssa.c | 2 ++ 3 files changed, 6 insertions(+)