From patchwork Mon Sep 10 12:53:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 182875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5FA462C059F for ; Mon, 10 Sep 2012 22:54:07 +1000 (EST) Received: from localhost ([::1]:44679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TB3V7-0000nb-Hs for incoming@patchwork.ozlabs.org; Mon, 10 Sep 2012 08:54:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TB3UR-0007Ju-Er for qemu-devel@nongnu.org; Mon, 10 Sep 2012 08:53:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TB3UD-0000bu-Jx for qemu-devel@nongnu.org; Mon, 10 Sep 2012 08:53:23 -0400 Received: from hall.aurel32.net ([88.191.126.93]:58361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TB3UD-0000be-DI for qemu-devel@nongnu.org; Mon, 10 Sep 2012 08:53:09 -0400 Received: from [46.27.32.65] (helo=ohm.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TB3UB-0004ab-MK; Mon, 10 Sep 2012 14:53:08 +0200 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.80) (envelope-from ) id 1TB3U9-000696-8I; Mon, 10 Sep 2012 14:53:05 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Mon, 10 Sep 2012 14:53:03 +0200 Message-Id: <1347281584-23491-3-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1347281584-23491-1-git-send-email-aurelien@aurel32.net> References: <1347281584-23491-1-git-send-email-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 88.191.126.93 Cc: Blue Swirl , Aurelien Jarno Subject: [Qemu-devel] [PATCH v2 2/3] tcg/optimize: fix end of basic bloc detection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit e31b0a7c050711884ad570fe73df806520953618 fixed copy propagation on 32-bit host by restricting the copy between different types. This was the wrong fix. The real problem is that the all temps states should be reset at the end of a basic bloc. This was done by adding such operations in the switch, but brcond2 was forgotten (that's why the crash was only observed on 32-bit hosts). Fix that by looking at the TCG_OPF_BB_END instead. We need to keep the case for op_set_label as temps might be modified through another path. Cc: Blue Swirl Signed-off-by: Aurelien Jarno --- tcg/optimize.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 9c65474..64aa35b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -487,22 +487,17 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, i--; } break; - case INDEX_op_set_label: - case INDEX_op_jmp: - case INDEX_op_br: - CASE_OP_32_64(brcond): - memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); - for (i = 0; i < def->nb_args; i++) { - *gen_args = *args; - args++; - gen_args++; - } - break; default: /* Default case: we do know nothing about operation so no - propagation is done. We only trash output args. */ - for (i = 0; i < def->nb_oargs; i++) { - reset_temp(args[i], nb_temps, nb_globals); + propagation is done. We trash everything if the operation + is the end of a basic block, otherwise we only trash the + output args. */ + if (def->flags & TCG_OPF_BB_END) { + memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); + } else { + for (i = 0; i < def->nb_oargs; i++) { + reset_temp(args[i], nb_temps, nb_globals); + } } for (i = 0; i < def->nb_args; i++) { gen_args[i] = args[i];