commit d96672c3e87b42ba8e269bd72386ee2431c3134c
Author: Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu Jun 2 08:14:12 2016 +0200
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Thu Jun 2 08:14:12 2016 +0200
[cc2-qbe] Add initial label for qbe
Qbe needs a label at the beginning of every basic block,
but when we don't have any code inside of a function we
does not generate any basic block. This code forces to
have at least one basic block composed of a label and
a jump statement.
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 2f213c5..6e23894 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -317,7 +317,7 @@ writeout(void)
break;
printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
}
- puts(")\n{");
+ puts(")\n{\[email protected]");
/* allocate stack space for parameters */
for (p = locals; p && (p->type.flags & PARF) != 0; p = p->next)
@@ -344,6 +344,8 @@ writeout(void)
if (pc->op)
(*optbl[pc->op].fun)();
}
+ if (!prog)
+ puts("\t\tret");
puts("}");
}