From 7b1850917ddbf1b8a4502df55339a2154bf00712 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 20 Dec 2012 21:01:46 +0900 Subject: [PATCH] Force RETURN's operand to be live. This seems to be the final fix to get return-ivar.r working. --- tools/qfcc/source/dags.c | 11 +++++++++++ tools/qfcc/test/Makefile.am | 8 ++++++++ tools/qfcc/test/return-ivar.r | 26 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tools/qfcc/test/return-ivar.r diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 333dfc27a..afd2037d4 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -54,6 +54,7 @@ #include "strpool.h" #include "symtab.h" #include "type.h" +#include "value.h" static daglabel_t *free_labels; static dagnode_t *free_nodes; @@ -372,6 +373,16 @@ dagnode_set_edges (dag_t *dag, dagnode_t *n) first_param = 2; } else if (!strncmp (n->label->opcode, "label->opcode + 5; + } else if (!strcmp (n->label->opcode, "")) { + daglabel_t *label = n->children[0]->label; + if (!label->op) { + set_iter_t *lab_i; + for (lab_i = set_first (n->children[0]->identifiers); lab_i; + lab_i = set_next (lab_i)) { + label = dag->labels[lab_i->value]; + } + } + label->live = 1; } if (num_params && isdigit (*num_params)) { for (i = first_param; i < *num_params - '0'; i++) { diff --git a/tools/qfcc/test/Makefile.am b/tools/qfcc/test/Makefile.am index 01f53cc27..1e2382d89 100644 --- a/tools/qfcc/test/Makefile.am +++ b/tools/qfcc/test/Makefile.am @@ -25,6 +25,7 @@ test_progs_dat=\ deadbool.dat \ infloop.dat \ modulo.dat \ + return-ivar.dat \ structlive.dat \ structptr.dat \ vecinit.dat \ @@ -84,6 +85,13 @@ modulo.dat: $(modulo_obj) $(QFCC_DEP) modulo.run: Makefile build-run TEST_HARNESS_OPTS=--float $(srcdir)/build-run $@ +return_ivar_dat_SOURCES=return-ivar.r +return_ivar_obj=$(return_ivar_dat_SOURCES:.r=.qfo) +return-ivar.dat: $(return_ivar_obj) $(QFCC_DEP) + $(QFCC) $(QCFLAGS) -o $@ $(return_ivar_obj) +return-ivar.run: Makefile build-run + $(srcdir)/build-run $@ + structlive_dat_SOURCES=structlive.r structlive_obj=$(structlive_dat_SOURCES:.r=.qfo) structlive.dat: $(structlive_obj) $(QFCC_DEP) diff --git a/tools/qfcc/test/return-ivar.r b/tools/qfcc/test/return-ivar.r new file mode 100644 index 000000000..ddac54234 --- /dev/null +++ b/tools/qfcc/test/return-ivar.r @@ -0,0 +1,26 @@ +typedef struct Point { + int x; + int y; +} Point; + +@interface Object //just so the runtime doesn't complain +{ + Class isa; + Point origin; +} +-(Point) origin; +@end +@implementation Object +-(Point) origin +{ + Point p; + p = origin; + return p; +} +@end +void __obj_exec_class (struct obj_module *msg) = #0; + +int main() +{ + return 0; +}