commit 3182c9c3bcfd64f88e0dbd3cd8a6cef26a49b237
parent e2095e94bb09dd13787cedd1fd382e3ef236b98e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 17 Jun 2016 14:31:25 +0200
[cc2-qbe] Fix additional return code
This additional return is added because we need
a jump instruction to the end of basic blocks,
but the last addition of OEFUN broke the previous
logic.
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/cc2/arch/qbe/optm.c b/cc2/arch/qbe/optm.c
@@ -11,7 +11,8 @@ optm_dep(Node *np)
Node *p, *dst, *next = np->next;
Symbol *sym, *osym;
- if (!next) {
+ switch (op) {
+ case OEFUN:
/*
* In QBE we need at the end of a basic block
* a jump, so we have to ensure that the last
@@ -22,12 +23,10 @@ optm_dep(Node *np)
* a ret there, and in the case of branches
* we need a label for the next statement
*/
- if (op == ONOP || op == OBRANCH || (op != ORET && op != OJMP))
+ op = (np->prev) ? np->prev->op : 0;
+ if (!op || op == ONOP || op == OBRANCH || (op != ORET && op != OJMP))
addstmt(newnode(ORET), KEEPCUR);
- next = np->next;
- }
-
- switch (op) {
+ break;
case ONOP:
if (next->op == ONOP) {
sym = np->u.sym;