commit bb663d195fde2e1d89e3700f82899b469cd3fb8c
parent 5ef65b780276437e03c0028b418a6be0ef23eba6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 17 Jun 2016 13:55:27 +0200
[cc2-qbe] Force to have a label in bb
Qbe needs a label at the beginning of every basic block
so we have to check this condition.
Diffstat:
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -304,6 +304,7 @@ writeout(void)
Symbol *p;
Type *tp;
char *sep, *name;
+ int haslabel;
if (curfun->kind == SGLOB)
fputs("export ", stdout);
@@ -315,14 +316,21 @@ writeout(void)
break;
printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
}
- puts(")\n{\n@.start");
+ puts(")\n{");
/* emit assembler instructions */
for (pc = prog; pc; pc = pc->next) {
- if (pc->label)
+ if (pc->label) {
+ haslabel = 1;
printf("%s\n", symname(pc->label));
- if (pc->op)
- (*optbl[pc->op].fun)();
+ }
+ if (!pc->op)
+ continue;
+ if (pc->flags&BBENTRY && !haslabel)
+ printf("%s\n", symname(newlabel()));
+ (*optbl[pc->op].fun)();
+ if (!pc->label)
+ haslabel = 0;
}
puts("}");
@@ -486,7 +494,8 @@ getbblocks(void)
case ASCALLL:
case ASCALLD:
case ASCALL:
- pc->flags |= BBENTRY;
+ if (pc->next)
+ pc->next->flags |= BBENTRY;
break;
}
}