From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jyr79-0002Gs-OP for qemu-devel@nongnu.org; Wed, 21 May 2008 12:24:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jyr78-0002FC-25 for qemu-devel@nongnu.org; Wed, 21 May 2008 12:24:30 -0400 Received: from [199.232.76.173] (port=42439 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jyr77-0002Es-O3 for qemu-devel@nongnu.org; Wed, 21 May 2008 12:24:29 -0400 Received: from savannah.gnu.org ([199.232.41.3]:46424 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jyr76-00055p-Jc for qemu-devel@nongnu.org; Wed, 21 May 2008 12:24:29 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Jyr72-0002Ty-Dk for qemu-devel@nongnu.org; Wed, 21 May 2008 16:24:25 +0000 Received: from bellard by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Jyr70-0002Tj-NZ for qemu-devel@nongnu.org; Wed, 21 May 2008 16:24:23 +0000 MIME-Version: 1.0 Errors-To: bellard Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fabrice Bellard Message-Id: Date: Wed, 21 May 2008 16:24:22 +0000 Subject: [Qemu-devel] [4512] fixed dead global variable update Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4512 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4512 Author: bellard Date: 2008-05-21 16:24:20 +0000 (Wed, 21 May 2008) Log Message: ----------- fixed dead global variable update Modified Paths: -------------- trunk/tcg/tcg.c Modified: trunk/tcg/tcg.c =================================================================== --- trunk/tcg/tcg.c 2008-05-21 13:34:27 UTC (rev 4511) +++ trunk/tcg/tcg.c 2008-05-21 16:24:20 UTC (rev 4512) @@ -1293,10 +1293,9 @@ 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,10 +1305,23 @@ 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]; if (ts->val_type != TEMP_VAL_CONST) { @@ -1481,14 +1493,7 @@ /* 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 @@ /* 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);