From patchwork Wed Oct 5 23:47:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 117943 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 EA7B9B6FD7 for ; Thu, 6 Oct 2011 10:48:03 +1100 (EST) Received: (qmail 28656 invoked by alias); 5 Oct 2011 23:48:01 -0000 Received: (qmail 28637 invoked by uid 22791); 5 Oct 2011 23:48:00 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Oct 2011 23:47:45 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1RBbBg-0006g9-09 from Bernd_Schmidt@mentor.com ; Wed, 05 Oct 2011 16:47:44 -0700 Received: from [127.0.0.1] ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 6 Oct 2011 00:47:42 +0100 Message-ID: <4E8CEC99.2000105@codesourcery.com> Date: Thu, 06 Oct 2011 01:47:37 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110920 Lightning/1.0b3pre Thunderbird/3.1.12 MIME-Version: 1.0 To: Ian Lance Taylor CC: Richard Henderson , Richard Guenther , GCC Patches , richard.sandiford@linaro.org Subject: Re: Initial shrink-wrapping patch References: <4E5E7342.9050103@codesourcery.com> <4E6E9857.50600@t-online.de> <4E6F37D9.9000108@t-online.de> <4E6F4B90.2050408@codesourcery.com> <4E6F786E.6080407@codesourcery.com> <4E712FD6.5030109@redhat.com> <4E8239ED.9020004@codesourcery.com> <4E85F395.3030006@redhat.com> <4E8B8469.2090605@codesourcery.com> <4E8B88E7.3090107@redhat.com> <4E8C7ED0.3090705@codesourcery.com> <4E8C83FA.3000607@redhat.com> <4E8C912C.2060805@codesourcery.com> In-Reply-To: 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 On 10/06/11 01:04, Ian Lance Taylor wrote: > On Wed, Oct 5, 2011 at 10:17 AM, Bernd Schmidt wrote: >> >> I've committed the following after a x86_64-linux bootstrap. > > This patch appears to have broken the Go bootstrap when compiling a C > file in libgo. Here is a reduced test case: > > static struct > { > int n; > unsigned int m; > _Bool f; > } g; > > _Bool > f (int s) > { > unsigned int b, m; > > if (!g.f) > return 0; > b = 1 << s; > while (1) > { > m = g.m; > if (m & b) > break; > if (__sync_bool_compare_and_swap (&g.m, m, m|b)) > { > if (m == 0) > f2 (&g.n); > break; > } > } > return 1; > } > > Compiling this file with -O2 -fsplit-stack causes an ICE: > > foo.c:29:1: internal compiler error: in maybe_record_trace_start, at > dwarf2cfi.c:2243 > > Compiling the file with -O2 -fsplit-stack -fno-shrink-wrap works. This appears to be because the split prologue contains a jump, which means the find_many_sub_blocks call reorders the block numbers, and our indices into bb_flags are off. I'm testing the following patch, but it won't finish today - feel free to test and check it in, or to just disable shrink-wrapping with split prologues. Bernd Index: gcc/function.c =================================================================== --- gcc/function.c (revision 179577) +++ gcc/function.c (working copy) @@ -5455,7 +5455,7 @@ thread_prologue_and_epilogue_insns (void basic_block last_bb; bool last_bb_active; #ifdef HAVE_simple_return - bool unconverted_simple_returns = false; + VEC (basic_block, heap) *unconverted_simple_returns = NULL; basic_block simple_return_block_hot = NULL; basic_block simple_return_block_cold = NULL; bool nonempty_prologue; @@ -5876,7 +5876,8 @@ thread_prologue_and_epilogue_insns (void { #ifdef HAVE_simple_return if (simple_p) - unconverted_simple_returns = true; + VEC_safe_push (basic_block, heap, + unconverted_simple_returns, bb); #endif continue; } @@ -5894,7 +5895,8 @@ thread_prologue_and_epilogue_insns (void { #ifdef HAVE_simple_return if (simple_p) - unconverted_simple_returns = true; + VEC_safe_push (basic_block, heap, + unconverted_simple_returns, bb); #endif continue; } @@ -6042,10 +6044,11 @@ epilogue_done: convert to conditional simple_returns, but couldn't for some reason, create a block to hold a simple_return insn and redirect those remaining edges. */ - if (unconverted_simple_returns) + if (!VEC_empty (basic_block, unconverted_simple_returns)) { - edge_iterator ei2; basic_block exit_pred = EXIT_BLOCK_PTR->prev_bb; + basic_block src_bb; + int i; gcc_assert (entry_edge != orig_entry_edge); @@ -6062,19 +6065,12 @@ epilogue_done: simple_return_block_cold = e->dest; } - restart_scan: - for (ei2 = ei_start (last_bb->preds); (e = ei_safe_edge (ei2)); ) + FOR_EACH_VEC_ELT (basic_block, unconverted_simple_returns, i, src_bb) { - basic_block bb = e->src; + edge e = find_edge (src_bb, last_bb); basic_block *pdest_bb; - if (bb == ENTRY_BLOCK_PTR - || bitmap_bit_p (&bb_flags, bb->index)) - { - ei_next (&ei2); - continue; - } - if (BB_PARTITION (e->src) == BB_HOT_PARTITION) + if (BB_PARTITION (src_bb) == BB_HOT_PARTITION) pdest_bb = &simple_return_block_hot; else pdest_bb = &simple_return_block_cold; @@ -6094,8 +6090,8 @@ epilogue_done: make_edge (bb, EXIT_BLOCK_PTR, 0); } redirect_edge_and_branch_force (e, *pdest_bb); - goto restart_scan; } + VEC_free (basic_block, heap, unconverted_simple_returns); } #endif