From patchwork Fri Jan 21 15:24:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 79851 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 7BA34B70A9 for ; Sat, 22 Jan 2011 02:24:35 +1100 (EST) Received: (qmail 8299 invoked by alias); 21 Jan 2011 15:24:34 -0000 Received: (qmail 8289 invoked by uid 22791); 21 Jan 2011 15:24:33 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Jan 2011 15:24:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0LFOFvT021010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Jan 2011 10:24:15 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0LFOES6001201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 21 Jan 2011 10:24:15 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0LFOEvU025851 for ; Fri, 21 Jan 2011 16:24:14 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0LFOEoE025814 for gcc-patches@gcc.gnu.org; Fri, 21 Jan 2011 16:24:14 +0100 Date: Fri, 21 Jan 2011 16:24:14 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -freorder-blocks-and-partition EH handling (PR middle-end/45566) Message-ID: <20110121152414.GI2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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! If with hot/cold section partitioning the first section of a function contains only nothrowing insns and this_action == -1 insns, but the second section starts (after optionally some nothrowing) with a this_action != -1 insn, convert_to_eh_region_ranges ICEs. The problem is that last_action in that case is -3, therefore the if (first_no_action_insn_before_switch) isn't then performed and on following insns last_action_insn is no longer equal to last_no_action_insn_before_switch. While looking at resulting assembly I've also noticed that it was incorrectly generating two sets of .LEHB0/.LEHB1 labels. Both issues fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-01-21 Jakub Jelinek PR middle-end/45566 * except.c (convert_to_eh_region_ranges): Emit queued no-region notes from other section in hot/cold partitioning even if last_action is -3. Increment call_site_base. * g++.dg/tree-prof/partition3.C: New test. Jakub --- gcc/except.c.jj 2011-01-18 12:20:18.000000000 +0100 +++ gcc/except.c 2011-01-21 13:11:07.000000000 +0100 @@ -2421,30 +2421,33 @@ convert_to_eh_region_ranges (void) if (last_action != this_action || last_landing_pad != this_landing_pad) { + /* If there is a queued no-action region in the other section + with hot/cold partitioning, emit it now. */ + if (first_no_action_insn_before_switch) + { + gcc_assert (this_action != -1 + && last_action == (first_no_action_insn + ? -1 : -3)); + call_site = add_call_site (NULL_RTX, 0, 0); + note = emit_note_before (NOTE_INSN_EH_REGION_BEG, + first_no_action_insn_before_switch); + NOTE_EH_HANDLER (note) = call_site; + note = emit_note_after (NOTE_INSN_EH_REGION_END, + last_no_action_insn_before_switch); + NOTE_EH_HANDLER (note) = call_site; + gcc_assert (last_action != -3 + || (last_action_insn + == last_no_action_insn_before_switch)); + first_no_action_insn_before_switch = NULL_RTX; + last_no_action_insn_before_switch = NULL_RTX; + call_site_base++; + } /* If we'd not seen a previous action (-3) or the previous action was must-not-throw (-2), then we do not need an end note. */ if (last_action >= -1) { /* If we delayed the creation of the begin, do it now. */ - if (first_no_action_insn_before_switch) - { - call_site = add_call_site (NULL_RTX, 0, 0); - note - = emit_note_before (NOTE_INSN_EH_REGION_BEG, - first_no_action_insn_before_switch); - NOTE_EH_HANDLER (note) = call_site; - if (first_no_action_insn) - { - note - = emit_note_after (NOTE_INSN_EH_REGION_END, - last_no_action_insn_before_switch); - NOTE_EH_HANDLER (note) = call_site; - } - else - gcc_assert (last_action_insn - == last_no_action_insn_before_switch); - } if (first_no_action_insn) { call_site = add_call_site (NULL_RTX, 0, cur_sec); --- gcc/testsuite/g++.dg/tree-prof/partition3.C.jj 2011-01-21 13:17:08.000000000 +0100 +++ gcc/testsuite/g++.dg/tree-prof/partition3.C 2011-01-21 13:16:05.000000000 +0100 @@ -0,0 +1,18 @@ +// PR middle-end/45566 +// { dg-require-effective-target freorder } +// { dg-options "-O -fnon-call-exceptions -freorder-blocks-and-partition" } + +int k; + +int +main () +{ + try + { + if (k) + throw 6; + } + catch (...) + { + } +} --- gcc/testsuite/g++.dg/tree-prof/tree-prof.exp.jj 2009-02-20 15:41:27.000000000 +0100 +++ gcc/testsuite/g++.dg/tree-prof/tree-prof.exp 2011-01-21 13:16:57.000000000 +0100 @@ -16,7 +16,7 @@ # . # Test the functionality of programs compiled with profile-directed block -# ordering using -fprofile-generate followed by -fbranch-use. +# ordering using -fprofile-generate followed by -fprofile-use. load_lib target-supports.exp