From 66a02fa7cec780fc88d6ef4cce7a1e704928808a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Sun, 9 Aug 2009 10:22:11 +0200
Subject: [PATCH] unssa: track uses when replacing a phi node
The output of test-unssa is inconsistent for a simple test-case without
this patch:
static void test(void **ptr)
{
while (ptr) {
ptr = *ptr;
}
}
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
flow.h | 1 +
liveness.c | 2 +-
unssa.c | 2 ++
3 files changed, 4 insertions(+), 1 deletions(-)
@@ -29,6 +29,7 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom
extern void clear_liveness(struct entrypoint *ep);
extern void track_pseudo_liveness(struct entrypoint *ep);
extern void track_pseudo_death(struct entrypoint *ep);
+extern void track_phi_uses(struct instruction *insn);
extern void vrfy_flow(struct entrypoint *ep);
extern int pseudo_in_list(struct pseudo_list *list, pseudo_t pseudo);
@@ -279,7 +279,7 @@ static void merge_pseudo_list(struct pseudo_list *src, struct pseudo_list **dest
} END_FOR_EACH_PTR(pseudo);
}
-static void track_phi_uses(struct instruction *insn)
+void track_phi_uses(struct instruction *insn)
{
pseudo_t phi;
FOR_EACH_PTR(insn->phi_list, phi) {
@@ -26,6 +26,7 @@
#include "lib.h"
#include "linearize.h"
#include "allocate.h"
+#include "flow.h"
#include <assert.h>
@@ -51,6 +52,7 @@ static void replace_phi_node(struct instruction *phi)
// update the current liveness
remove_pseudo(&phi->bb->needs, phi->target);
add_pseudo(&phi->bb->needs, tmp);
+ track_phi_uses(phi);
phi->opcode = OP_COPY;
phi->src = tmp;
--
1.6.4