aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flow.c2
-rw-r--r--linearize.c18
-rw-r--r--linearize.h1
-rw-r--r--memops.c1
4 files changed, 19 insertions, 3 deletions
diff --git a/flow.c b/flow.c
index d67322a..dc9683e 100644
--- a/flow.c
+++ b/flow.c
@@ -255,6 +255,7 @@ no_dominance:
found_dominator:
br = delete_last_instruction(&parent->insns);
phi = alloc_phi(parent, one->target, one->size);
+ phi->ident = phi->ident ? : pseudo->ident;
add_instruction(&parent->insns, br);
use_pseudo(phi, add_pseudo(dominators, phi));
} END_FOR_EACH_PTR(parent);
@@ -277,6 +278,7 @@ void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *domi
FOR_EACH_PTR(dominators, phi) {
if (new != phi->def->src1)
goto complex_phi;
+ new->ident = new->ident ? : phi->ident;
} END_FOR_EACH_PTR(phi);
/*
diff --git a/linearize.c b/linearize.c
index 31e1d39..a3a5a38 100644
--- a/linearize.c
+++ b/linearize.c
@@ -79,6 +79,7 @@ static const char *show_pseudo(pseudo_t pseudo)
static int n;
static char buffer[4][64];
char *buf;
+ int i;
if (!pseudo)
return "no pseudo";
@@ -115,7 +116,9 @@ static const char *show_pseudo(pseudo_t pseudo)
}
}
case PSEUDO_REG:
- snprintf(buf, 64, "%%r%d", pseudo->nr);
+ i = snprintf(buf, 64, "%%r%d", pseudo->nr);
+ if (pseudo->ident)
+ sprintf(buf+i, "(%s)", show_ident(pseudo->ident));
break;
case PSEUDO_VAL: {
long long value = pseudo->value;
@@ -129,7 +132,9 @@ static const char *show_pseudo(pseudo_t pseudo)
snprintf(buf, 64, "%%arg%d", pseudo->nr);
break;
case PSEUDO_PHI:
- snprintf(buf, 64, "%%phi%d", pseudo->nr);
+ i = snprintf(buf, 64, "%%phi%d", pseudo->nr);
+ if (pseudo->ident)
+ sprintf(buf+i, "(%s)", show_ident(pseudo->ident));
break;
default:
snprintf(buf, 64, "<bad pseudo type %d>", pseudo->type);
@@ -388,10 +393,10 @@ void show_instruction(struct instruction *insn)
static void show_bb(struct basic_block *bb)
{
struct instruction *insn;
- pseudo_t needs;
printf(".L%p:\n", bb);
if (verbose) {
+ pseudo_t needs, defines;
printf("%s:%d\n", input_streams[bb->pos.stream].name, bb->pos.line);
FOR_EACH_PTR(bb->needs, needs) {
@@ -412,6 +417,10 @@ static void show_bb(struct basic_block *bb)
}
} END_FOR_EACH_PTR(needs);
+ FOR_EACH_PTR(bb->defines, defines) {
+ printf(" **defines %s **\n", show_pseudo(defines));
+ } END_FOR_EACH_PTR(defines);
+
if (bb->parents) {
struct basic_block *from;
FOR_EACH_PTR(bb->parents, from) {
@@ -692,6 +701,7 @@ static pseudo_t symbol_pseudo(struct entrypoint *ep, struct symbol *sym)
pseudo = __alloc_pseudo(0);
pseudo->type = PSEUDO_SYM;
pseudo->sym = sym;
+ pseudo->ident = sym->ident;
sym->pseudo = pseudo;
add_symbol(&ep->accesses, sym);
}
@@ -1525,6 +1535,7 @@ pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stmt)
add_instruction(&bb_return->insns, phi_node);
}
phi = alloc_phi(active, src, expr->ctype->bit_size);
+ phi->ident = &return_ident;
use_pseudo(phi, add_pseudo(&phi_node->phi_list, phi));
}
add_goto(ep, bb_return);
@@ -1782,6 +1793,7 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t
merge_phi_sources = 1;
do {
cleanup_and_cse(ep);
+ simplify_flow(ep);
pack_basic_blocks(ep);
} while (repeat_phase & REPEAT_CSE);
diff --git a/linearize.h b/linearize.h
index 72cf4dd..0db5a43 100644
--- a/linearize.h
+++ b/linearize.h
@@ -22,6 +22,7 @@ struct pseudo {
int nr;
enum pseudo_type type;
struct pseudo_ptr_list *users;
+ struct ident *ident;
union {
struct symbol *sym;
struct instruction *def;
diff --git a/memops.c b/memops.c
index eac76cd..2781fad 100644
--- a/memops.c
+++ b/memops.c
@@ -64,6 +64,7 @@ no_dominance:
found_dominator:
br = delete_last_instruction(&parent->insns);
phi = alloc_phi(parent, one->target, one->size);
+ phi->ident = phi->ident ? : one->target->ident;
add_instruction(&parent->insns, br);
use_pseudo(phi, add_pseudo(dominators, phi));
} END_FOR_EACH_PTR(parent);