scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 809d26d10849761118aefc680c9ae7d01b813c4a
parent 217331e8371160ff041a36e348b9a50ce3b81043
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  9 May 2016 11:32:51 +0200

[cc2-qbe] Ensure correctness of basic blocks

We have to take care of how basic blocks are built in QBE,
so we have to ensure that all the basic blocks of the program
are finalized with a jump of any type. We also need a label
in the next statement of a branch, because in branches in QBE
we have to use one label for true and another one for false.

Diffstat:
Mcc2/arch/qbe/cgen.c | 9+--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -225,14 +225,7 @@ cgen(Node *np) if (!np) return NULL; - if (np->label) { - setlabel(np->label); - if (np->next == NULL) { - Node *tmp = newnode(); - tmp->op = ORET; - addstmt(tmp, KEEPCUR); - } - } + setlabel(np->label); l = cgen(np->left); r = cgen(np->right); tp = &np->type;