diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-21 16:24:20 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-21 16:24:20 +0000 |
commit | e5097dc8e3beb5cc94d132681db7a2433bdce5a7 (patch) | |
tree | cf76e48c421264132a65ab044d513e1ff8b379d5 /tcg/tcg.c | |
parent | 839bca8467a503171c3f12449434fa12cba2dc29 (diff) | |
download | hqemu-e5097dc8e3beb5cc94d132681db7a2433bdce5a7.zip hqemu-e5097dc8e3beb5cc94d132681db7a2433bdce5a7.tar.gz |
fixed dead global variable update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4512 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tcg/tcg.c')
-rw-r--r-- | tcg/tcg.c | 38 |
1 files changed, 18 insertions, 20 deletions
@@ -1293,10 +1293,9 @@ static int tcg_reg_alloc(TCGContext *s, TCGRegSet reg1, TCGRegSet reg2) tcg_abort(); } -/* at the end of a basic block, we assume all temporaries are dead and - all globals are stored at their canonical location */ -/* XXX: optimize by handling constants in another array ? */ -void tcg_reg_alloc_bb_end(TCGContext *s) +/* save globals to their cannonical location and assume they can be + modified be the following code. */ +static void save_globals(TCGContext *s) { TCGTemp *ts; int i; @@ -1306,9 +1305,22 @@ void tcg_reg_alloc_bb_end(TCGContext *s) if (!ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) { tcg_reg_free(s, ts->reg); + } else if (ts->val_type == TEMP_VAL_DEAD) { + ts->val_type = TEMP_VAL_MEM; } } } +} + +/* at the end of a basic block, we assume all temporaries are dead and + all globals are stored at their canonical location */ +/* XXX: optimize by handling constants in another array ? */ +void tcg_reg_alloc_bb_end(TCGContext *s) +{ + TCGTemp *ts; + int i; + + save_globals(s); for(i = s->nb_globals; i < s->nb_temps; i++) { ts = &s->temps[i]; @@ -1481,14 +1493,7 @@ static void tcg_reg_alloc_op(TCGContext *s, /* store globals and free associated registers (we assume the insn can modify any global. */ - for(i = 0; i < s->nb_globals; i++) { - ts = &s->temps[i]; - if (!ts->fixed_reg) { - if (ts->val_type == TEMP_VAL_REG) { - tcg_reg_free(s, ts->reg); - } - } - } + save_globals(s); } /* satisfy the output constraints */ @@ -1680,14 +1685,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, /* store globals and free associated registers (we assume the call can modify any global. */ - for(i = 0; i < s->nb_globals; i++) { - ts = &s->temps[i]; - if (!ts->fixed_reg) { - if (ts->val_type == TEMP_VAL_REG) { - tcg_reg_free(s, ts->reg); - } - } - } + save_globals(s); tcg_out_op(s, opc, &func_arg, &const_func_arg); |