From ca818eaff8047986df33ba80ec7bc0d0a1104228 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 3 Feb 2022 16:33:42 +0900 Subject: [PATCH] [qfcc] Ensure ops on globals occur before return This fixes the return-postop test, and covers calls, too. --- tools/qfcc/source/dags.c | 14 +++++++++++++- tools/qfcc/test/Makemodule.am | 3 +-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 9e3b1cdab..57ed83545 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -450,7 +450,8 @@ dagnode_set_edges (dag_t *dag, dagnode_t *n) if (n->type == st_func) { const char *num_params = 0; int first_param = 0; - flowvar_t **flowvars = dag->flownode->graph->func->vars; + function_t *func = dag->flownode->graph->func; + flowvar_t **flowvars = func->vars; if (!strncmp (n->label->opcode, "label->opcode + 6; @@ -468,6 +469,17 @@ dagnode_set_edges (dag_t *dag, dagnode_t *n) } label->live = 1; } + // ensure all operantions on global variables are completed before + // the st_func statement executes + for (set_iter_t *g = set_first (func->global_vars); g; + g = set_next (g)) { + flowvar_t *var = flowvars[g->element]; + dagnode_t *gn = dag_node (var->op); + if (gn) { + set_add (n->edges, gn->number); + set_remove (gn->edges, n->number); + } + } if (num_params && isdigit (*num_params)) { for (i = first_param; i < *num_params - '0'; i++) { flowvar_t *var = flowvars[i + 1]; diff --git a/tools/qfcc/test/Makemodule.am b/tools/qfcc/test/Makemodule.am index 9f4caac0a..08137d7e3 100644 --- a/tools/qfcc/test/Makemodule.am +++ b/tools/qfcc/test/Makemodule.am @@ -63,8 +63,7 @@ test_progs_dat=\ tools/qfcc/test/while.dat \ tools/qfcc/test/zerolinker.dat -fail_progs_dat=\ - tools/qfcc/test/return-postop.dat +fail_progs_dat= test_build_errors=\ tools/qfcc/test/classarray.r \