commit e1468117aa0dcf5b43dfec797a8dbfb3531d3bff
parent 09fa67e950f46b3c661d5d1e34623b2c7177f6d1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 9 Aug 2014 18:31:49 +0200
Emit preamble only when it is needed
If there is no local variables in stac don't emit the preamble
because is useless. This causes that backtraces cannot be generated,
so emit preamble always in debug mode.
Diffstat:
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/cc2/cgen.c b/cc2/cgen.c
@@ -79,15 +79,24 @@ emit(char op, ...)
void
cgen(Symbol *sym, Node *list[])
{
+ extern char odebug;
+ char frame = sym->u.f.stack != 0 || odebug;
+
emit(ADDR, sym->u.f.name);
- emit(PUSH, IX);
- emit(LD, IX, SP);
- emit(LDI, HL, -sym->u.f.stack);
- emit(ADD, HL, SP);
- emit(LD, SP, HL);
- emit(LD, SP, IX);
- emit(POP, IX);
- emit(RET);
+ if (frame) {
+ emit(PUSH, IX);
+ emit(LD, IX, SP);
+ emit(LDI, HL, -sym->u.f.stack);
+ emit(ADD, HL, SP);
+ emit(LD, SP, HL);
+ }
+
+
+ if (frame) {
+ emit(LD, SP, IX);
+ emit(POP, IX);
+ emit(RET);
+ }
}
/*
diff --git a/cc2/main.c b/cc2/main.c
@@ -11,6 +11,8 @@
extern void parse(void);
+char odebug;
+
void
error(unsigned nerror, ...)
{