Commit e5097dc8e3beb5cc94d132681db7a2433bdce5a7
1 parent
839bca84
fixed dead global variable update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4512 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
18 additions
and
20 deletions
tcg/tcg.c
| ... | ... | @@ -1293,10 +1293,9 @@ static int tcg_reg_alloc(TCGContext *s, TCGRegSet reg1, TCGRegSet reg2) |
| 1293 | 1293 | tcg_abort(); |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | -/* at the end of a basic block, we assume all temporaries are dead and | |
| 1297 | - all globals are stored at their canonical location */ | |
| 1298 | -/* XXX: optimize by handling constants in another array ? */ | |
| 1299 | -void tcg_reg_alloc_bb_end(TCGContext *s) | |
| 1296 | +/* save globals to their cannonical location and assume they can be | |
| 1297 | + modified be the following code. */ | |
| 1298 | +static void save_globals(TCGContext *s) | |
| 1300 | 1299 | { |
| 1301 | 1300 | TCGTemp *ts; |
| 1302 | 1301 | int i; |
| ... | ... | @@ -1306,9 +1305,22 @@ void tcg_reg_alloc_bb_end(TCGContext *s) |
| 1306 | 1305 | if (!ts->fixed_reg) { |
| 1307 | 1306 | if (ts->val_type == TEMP_VAL_REG) { |
| 1308 | 1307 | tcg_reg_free(s, ts->reg); |
| 1308 | + } else if (ts->val_type == TEMP_VAL_DEAD) { | |
| 1309 | + ts->val_type = TEMP_VAL_MEM; | |
| 1309 | 1310 | } |
| 1310 | 1311 | } |
| 1311 | 1312 | } |
| 1313 | +} | |
| 1314 | + | |
| 1315 | +/* at the end of a basic block, we assume all temporaries are dead and | |
| 1316 | + all globals are stored at their canonical location */ | |
| 1317 | +/* XXX: optimize by handling constants in another array ? */ | |
| 1318 | +void tcg_reg_alloc_bb_end(TCGContext *s) | |
| 1319 | +{ | |
| 1320 | + TCGTemp *ts; | |
| 1321 | + int i; | |
| 1322 | + | |
| 1323 | + save_globals(s); | |
| 1312 | 1324 | |
| 1313 | 1325 | for(i = s->nb_globals; i < s->nb_temps; i++) { |
| 1314 | 1326 | ts = &s->temps[i]; |
| ... | ... | @@ -1481,14 +1493,7 @@ static void tcg_reg_alloc_op(TCGContext *s, |
| 1481 | 1493 | |
| 1482 | 1494 | /* store globals and free associated registers (we assume the insn |
| 1483 | 1495 | can modify any global. */ |
| 1484 | - for(i = 0; i < s->nb_globals; i++) { | |
| 1485 | - ts = &s->temps[i]; | |
| 1486 | - if (!ts->fixed_reg) { | |
| 1487 | - if (ts->val_type == TEMP_VAL_REG) { | |
| 1488 | - tcg_reg_free(s, ts->reg); | |
| 1489 | - } | |
| 1490 | - } | |
| 1491 | - } | |
| 1496 | + save_globals(s); | |
| 1492 | 1497 | } |
| 1493 | 1498 | |
| 1494 | 1499 | /* satisfy the output constraints */ |
| ... | ... | @@ -1680,14 +1685,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, |
| 1680 | 1685 | |
| 1681 | 1686 | /* store globals and free associated registers (we assume the call |
| 1682 | 1687 | can modify any global. */ |
| 1683 | - for(i = 0; i < s->nb_globals; i++) { | |
| 1684 | - ts = &s->temps[i]; | |
| 1685 | - if (!ts->fixed_reg) { | |
| 1686 | - if (ts->val_type == TEMP_VAL_REG) { | |
| 1687 | - tcg_reg_free(s, ts->reg); | |
| 1688 | - } | |
| 1689 | - } | |
| 1690 | - } | |
| 1688 | + save_globals(s); | |
| 1691 | 1689 | |
| 1692 | 1690 | tcg_out_op(s, opc, &func_arg, &const_func_arg); |
| 1693 | 1691 | ... | ... |