From 4c79c9ffaf46b8c2c35c8ce8205ed2a403b6ab1a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 1 Apr 2020 16:03:12 +0900 Subject: [PATCH] [qfcc] Do a dags pre-pass to give operands leafs The reason double-alias fails is when the double assignment occurs, the int operands don't yet have leaf nodes and thus the nodes cannot be killed. This doesn't fix the bug. --- tools/qfcc/source/dags.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 8b352e1c1..83c30b8b7 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -245,7 +245,21 @@ dag_node (operand_t *op) } static void -dag_make_children (dag_t *dag, statement_t *s, operand_t *operands[4], +dag_make_leafs (dag_t *dag, statement_t *s, operand_t *operands[FLOW_OPERANDS]) +{ + int i; + + flow_analyze_statement (s, 0, 0, 0, operands); + for (i = 1; i < FLOW_OPERANDS; i++) { + if (!dag_node (operands[i])) { + leaf_node (dag, operands[i], s->expr); + } + } +} + +static void +dag_make_children (dag_t *dag, statement_t *s, + operand_t *operands[FLOW_OPERANDS], dagnode_t *children[3]) { int i; @@ -730,6 +744,13 @@ dag_create (flownode_t *flownode) dag->labels = alloca (num_lables * sizeof (daglabel_t)); dag->roots = set_new (); + // do a first pass to ensure all operands have an "x_0" leaf node + // prior do actual dag creation + for (s = block->statements; s; s = s->next) { + operand_t *operands[FLOW_OPERANDS]; + dag_make_leafs (dag, s, operands); + } + // actual dag creation for (s = block->statements; s; s = s->next) { operand_t *operands[FLOW_OPERANDS]; dagnode_t *n = 0, *children[3] = {0, 0, 0};