[hackers] [scc] [cc2-qbe] Jump at the end in switches || Roberto E. Vargas Caballero
commit 95ac9724aaa7e8aecbfc0b354ab30a096c08ebbd
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Sep 28 11:49:57 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Sep 28 11:49:57 2016 +0200
[cc2-qbe] Jump at the end in switches
When we arrive to the end of a switch if-else-if chain
we have to jump to the default label. If we do not have
default case it means that we have to jump to the end of
the switch, but we always have to jump.
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 1c7b8fb..39ee9ec 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -428,12 +428,12 @@ swtch_if(Node *idx)
switch (np->op) {
case OESWITCH:
- if (deflabel) {
- aux1.op = OJMP;
- aux1.label = NULL;
- aux1.u.sym = deflabel;
- cgen(&aux1);
- }
+ if (!deflabel)
+ deflabel = np->u.sym;
+ aux1.op = OJMP;
+ aux1.label = NULL;
+ aux1.u.sym = deflabel;
+ cgen(&aux1);
return;
case OCASE:
aux1 = *np;
Received on Wed Sep 28 2016 - 11:52:29 CEST
This archive was generated by hypermail 2.3.0
: Wed Sep 28 2016 - 12:00:17 CEST