[hackers] [scc] [cc2-qbe] Fix additional return code || Roberto E. Vargas Caballero
commit 3182c9c3bcfd64f88e0dbd3cd8a6cef26a49b237
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jun 17 14:31:25 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jun 17 14:31:25 2016 +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.
diff --git a/cc2/arch/qbe/optm.c b/cc2/arch/qbe/optm.c
index a614b75..929d976 100644
--- a/cc2/arch/qbe/optm.c
+++ b/cc2/arch/qbe/optm.c
_AT_@ -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
_AT_@ -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;
Received on Fri Jun 17 2016 - 14:34:57 CEST
This archive was generated by hypermail 2.3.0
: Fri Jun 17 2016 - 14:36:15 CEST