From patchwork Fri May 13 17:13:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 95495 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 A5B10B6EF2 for ; Sat, 14 May 2011 02:08:25 +1000 (EST) Received: (qmail 13927 invoked by alias); 13 May 2011 16:08:20 -0000 Received: (qmail 13917 invoked by uid 22791); 13 May 2011 16:08:18 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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, 13 May 2011 16:07:58 +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.14.4/8.14.4) with ESMTP id p4DG7wgj030753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 May 2011 12:07:58 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4DG7wnY008589; Fri, 13 May 2011 12:07:58 -0400 Received: from 1005.home (ovpn-113-50.phx2.redhat.com [10.3.113.50]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p4DG7uKS009458; Fri, 13 May 2011 12:07:57 -0400 Message-ID: <4DCD66BA.6040704@redhat.com> Date: Fri, 13 May 2011 13:13:30 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches CC: Jeff Law Subject: RFA: patch to fix PR48633. 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 The patch fixes PR48633 described on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48633. The patch was successfully bootstrapped on x86-64. Ok to commit? 2011-05-13 Vladimir Makarov PR rtl-optimization/48633 * ira-build.c (loop_with_eh_edge_p): New function. (mark_loops_for_removal): Use it. 2011-05-13 Michael Matz PR rtl-optimization/48633 * g++.dg/pr48633.C: New test. Index: testsuite/g++.dg/pr48633.C =================================================================== --- testsuite/g++.dg/pr48633.C (revision 0) +++ testsuite/g++.dg/pr48633.C (revision 0) @@ -0,0 +1,28 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fira-region=all -fnon-call-exceptions" } */ +extern long double getme (void); +extern void useme (long double); +struct Frame { + long double tmp; +}; +void bugme (int n, long double ld1, long double ld2, long double ld3, + long double ld4, long double ld5) +{ + Frame f; + int i; + f.tmp = getme(); + try { + for (i = 0; i < n; i++) + { + f.tmp += 1.0; + } + } catch (...) { + f.tmp += 1.0; + } + ld1++; + ld2++; + ld3++; + ld4++; + ld5++; + useme (f.tmp); +} Index: ira-build.c =================================================================== --- ira-build.c (revision 173623) +++ ira-build.c (working copy) @@ -1806,6 +1806,25 @@ low_pressure_loop_node_p (ira_loop_tree_ return true; } +/* Return TRUE if LOOP has a EH enter or exit edge. */ +static bool +loop_with_eh_edge_p (struct loop *loop) +{ + int i; + edge_iterator ei; + edge e; + VEC (edge, heap) *edges; + + FOR_EACH_EDGE (e, ei, loop->header->preds) + if (e->flags & EDGE_EH) + return true; + edges = get_loop_exit_edges (loop); + FOR_EACH_VEC_ELT (edge, edges, i, e) + if (e->flags & EDGE_EH) + return true; + return false; +} + /* Sort loops for marking them for removal. We put already marked loops first, then less frequent loops next, and then outer loops next. */ @@ -1829,14 +1848,18 @@ loop_compare_func (const void *v1p, cons return l1->loop->num - l2->loop->num; } - /* Mark loops which should be removed from regional allocation. We remove a loop with low register pressure inside another loop with register pressure. In this case a separate allocation of the loop hardly helps (for irregular register file architecture it could help by choosing a better hard register in the loop but we prefer faster allocation even in this case). We also remove cheap loops - if there are more than IRA_MAX_LOOPS_NUM of them. */ + if there are more than IRA_MAX_LOOPS_NUM of them. Loop with EH + exit or enter edges are removed too because the allocation might + require put pseudo moves on the EH edges (we could still do this + for pseudos with caller saved hard registers in some cases but it + is impossible to say here or during top-down allocation pass what + hard register the pseudos get finally). */ static void mark_loops_for_removal (void) { @@ -1859,8 +1882,9 @@ mark_loops_for_removal (void) } sorted_loops[n++] = &ira_loop_nodes[i]; ira_loop_nodes[i].to_remove_p - = (low_pressure_loop_node_p (ira_loop_nodes[i].parent) - && low_pressure_loop_node_p (&ira_loop_nodes[i])); + = ((low_pressure_loop_node_p (ira_loop_nodes[i].parent) + && low_pressure_loop_node_p (&ira_loop_nodes[i])) + || loop_with_eh_edge_p (ira_loop_nodes[i].loop)); } qsort (sorted_loops, n, sizeof (ira_loop_tree_node_t), loop_compare_func); for (i = 0; n - i + 1 > IRA_MAX_LOOPS_NUM; i++)