ref: 59747e56d427dd7c5718042ee87d1b73231fe55a
parent: e1cd16b3c9ed2ae62c14d078b49351eb62824617
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jun 2 04:14:12 EDT 2016
[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.
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -317,7 +317,7 @@
break;
printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
}
- puts(")\n{");
+ puts(")\n{\n@.start");
/* allocate stack space for parameters */
for (p = locals; p && (p->type.flags & PARF) != 0; p = p->next)
@@ -344,6 +344,8 @@
if (pc->op)
(*optbl[pc->op].fun)();
}
+ if (!prog)
+ puts("\t\tret");
puts("}");
}