From patchwork Wed Oct 17 20:48:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwaran Raman X-Patchwork-Id: 192141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 947F32C008E for ; Thu, 18 Oct 2012 07:48:49 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351111729; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=rs2zA3l wEqVYvWY9JoLeBax2p0w=; b=whxoU+YvubnWNxOPsKycAgZJEplIACdFCuRK3h/ 997idhTg19GmpFaUoskDna3c/4ObxuwKBFfLetkZDsrwnKVM9qsg1O2atEnYlHVQ IvL7/8lRidsNYo2nrOq4dc/2ESYt90poPbdPQqCcBJb48yfLprLfUP36aBq4IFM/ FjQc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=EGm+Rsp9N30E2XU0kn2AN+5ImugQW1+eB1khxJMmOUb7Drja2gL3oGCJUtUK5d l98BcUoZxE3CGfBPnvnAvzt4pbIELBL4HPRmwpiQ0yfeOc2F0IKUU1Db4YptD7lA Tt9wiEPnHA20g/MCuxX5zSnSNNh/7vSyvSMqJ0fuL6r20=; Received: (qmail 3838 invoked by alias); 17 Oct 2012 20:48:44 -0000 Received: (qmail 3808 invoked by uid 22791); 17 Oct 2012 20:48:43 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-oa0-f47.google.com (HELO mail-oa0-f47.google.com) (209.85.219.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Oct 2012 20:48:38 +0000 Received: by mail-oa0-f47.google.com with SMTP id h1so8646550oag.20 for ; Wed, 17 Oct 2012 13:48:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-system-of-record:x-gm-message-state; bh=0gcEHSrz+RbzBQVh9Kl4BFikmyHjaWAfR/V0VvsFFEg=; b=ctN8cJbkyT/tV2nTp+nKD//zpLU2HfSYnSgipXI8kyy3PGPzB83eZECt2NvaiMzDgL Hzk8hIRpfrQPNc/W40KNJSPzTxGaYaEGmoLo1j0qBMx+SaHMMKl9BKIKv72IIlvk+thO ADYY/Ct+Fx9sTL0SD3GKebaUJkkiRlDIs1L9/H1rP00iaZkSRXhWC4HZ+y3GFbrDaYvI Js9x5pU+7RHIssRChgIJXECWJQ2sgh8+OOYcT0y03Oo25wAgdXFLi0lUg2i/ZnnMFFiL k+6o14aai7B9p+dJeOgbC097AzDqyon1ZzhvHLYmrUWVbHUQHLij1TjxSs3UMyynF4AU Fd1A== MIME-Version: 1.0 Received: by 10.60.28.167 with SMTP id c7mr17075765oeh.44.1350506918119; Wed, 17 Oct 2012 13:48:38 -0700 (PDT) Received: by 10.76.83.2 with HTTP; Wed, 17 Oct 2012 13:48:37 -0700 (PDT) Date: Wed, 17 Oct 2012 13:48:37 -0700 Message-ID: Subject: Fix bugs introduced by switch-case profile propagation From: Easwaran Raman To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka X-System-Of-Record: true X-Gm-Message-State: ALoCoQkOYT0OD+++vIlC9qZ05IZ75vgCCOlmtSLcTKyPTilTWXa425svw+eaonNq6mx1m2d9Yrt7G5+r8VyPTf1DdrH4QxFWQdjuB6sS8ozuiya+/xTRQ53CckFk4NzRDg0QOuDUvzFISUYLgxVi0GYlEtgY5PFV/O5oNaioapAhQj3XSAHO64jXhDmVQJXNR8hHnWet1/TI X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, This patch fixes bugs introduced by my previous patch to propagate profiles during switch expansion. Bootstrap and profiledbootstrap successful on x86_64. Confirmed that it fixes the crashes reported in PR middle-end/54957. OK for trunk? - Easwaran 2012-10-17 Easwaran Raman PR target/54938 PR middle-end/54957 * optabs.c (emit_cmp_and_jump_insn_1): Add REG_BR_PROB note only if it doesn't already exist. * except.c (sjlj_emit_function_enter): Remove unused variable. * stmt.c (get_outgoing_edge_probs): Return 0 if BB is NULL. (emit_case_dispatch_table): Handle the case where STMT_BB is NULL. (expand_sjlj_dispatch_table): Pass BB containing before_case to emit_case_dispatch_table. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c (revision 192488) +++ gcc/optabs.c (working copy) @@ -4268,11 +4268,9 @@ emit_cmp_and_jump_insn_1 (rtx test, enum machine_m && profile_status != PROFILE_ABSENT && insn && JUMP_P (insn) - && any_condjump_p (insn)) - { - gcc_assert (!find_reg_note (insn, REG_BR_PROB, 0)); - add_reg_note (insn, REG_BR_PROB, GEN_INT (prob)); - } + && any_condjump_p (insn) + && !find_reg_note (insn, REG_BR_PROB, 0)) + add_reg_note (insn, REG_BR_PROB, GEN_INT (prob)); } /* Generate code to compare X with Y so that the condition codes are Index: gcc/except.c =================================================================== --- gcc/except.c (revision 192488) +++ gcc/except.c (working copy) @@ -1153,7 +1153,7 @@ sjlj_emit_function_enter (rtx dispatch_label) if (dispatch_label) { #ifdef DONT_USE_BUILTIN_SETJMP - rtx x, last; + rtx x; x = emit_library_call_value (setjmp_libfunc, NULL_RTX, LCT_RETURNS_TWICE, TYPE_MODE (integer_type_node), 1, plus_constant (Pmode, XEXP (fc, 0), Index: gcc/stmt.c =================================================================== --- gcc/stmt.c (revision 192488) +++ gcc/stmt.c (working copy) @@ -1867,6 +1867,8 @@ get_outgoing_edge_probs (basic_block bb) edge e; edge_iterator ei; int prob_sum = 0; + if (!bb) + return 0; FOR_EACH_EDGE(e, ei, bb->succs) prob_sum += e->probability; return prob_sum; @@ -1916,8 +1918,8 @@ emit_case_dispatch_table (tree index_expr, tree in rtx fallback_label = label_rtx (case_list->code_label); rtx table_label = gen_label_rtx (); bool has_gaps = false; - edge default_edge = EDGE_SUCC(stmt_bb, 0); - int default_prob = default_edge->probability; + edge default_edge = stmt_bb ? EDGE_SUCC(stmt_bb, 0) : NULL; + int default_prob = default_edge ? default_edge->probability : 0; int base = get_outgoing_edge_probs (stmt_bb); bool try_with_tablejump = false; @@ -1997,7 +1999,8 @@ emit_case_dispatch_table (tree index_expr, tree in default_prob = 0; } - default_edge->probability = default_prob; + if (default_edge) + default_edge->probability = default_prob; /* We have altered the probability of the default edge. So the probabilities of all other edges need to be adjusted so that it sums up to @@ -2289,7 +2292,8 @@ expand_sjlj_dispatch_table (rtx dispatch_index, emit_case_dispatch_table (index_expr, index_type, case_list, default_label, - minval, maxval, range, NULL); + minval, maxval, range, + BLOCK_FOR_INSN (before_case)); emit_label (default_label); free_alloc_pool (case_node_pool); }