From patchwork Wed Jan 26 21:11:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 80552 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 648D2B7109 for ; Thu, 27 Jan 2011 08:14:58 +1100 (EST) Received: (qmail 19394 invoked by alias); 26 Jan 2011 21:14:52 -0000 Received: (qmail 19384 invoked by uid 22791); 26 Jan 2011 21:14:51 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_CF X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Jan 2011 21:14:40 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2CAF9CB02A0 for ; Wed, 26 Jan 2011 22:14:38 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Szd+nc85y4BP for ; Wed, 26 Jan 2011 22:14:38 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 067D0CB01B2 for ; Wed, 26 Jan 2011 22:14:38 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR rtl-optimization/44469 Date: Wed, 26 Jan 2011 22:11:52 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201101262211.53171.ebotcazou@adacore.com> 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 This is a regression present on the mainline and 4.5 branch for the ARM. The compiler aborts at -O2 during basic block reordering pass on code involving __builtin_unreachable () because of a dangling conditional jump. As diagnosed by Jakub, the problem is that, while cleanup_cfg removes an empty block present right before the barrier generated for __builtin_unreachable, it doesn't turn the conditional jump that jumps to it into an unconditional jump to the other branch. Now try_optimize_cfg already knows to do that; the problem is only that it fails to iterate after removing the empty block because of these lines: delete_basic_block (b); if (!(mode & CLEANUP_CFGLAYOUT)) changed = true; In CFG layout mode, deleting the block isn't recognized as changing something. The reasons for this are unclear, the line dates back to the introduction of the CFG layout mode in 2003; no comment, not even a mention in the ChangeLog. The context was actually different, there was originally a loop there. So I think that they are very likely obsolete by now and can be safely altered. Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline and 4.5 branch. 2011-01-26 Eric Botcazou PR rtl-optimization/44469 * cfgcleanup.c (try_optimize_cfg): Iterate in CFG layout mode too after removing trivially dead basic blocks. 2011-01-26 Eric Botcazou * gcc.c-torture/compile/20110126-1.c: New test. Index: cfgcleanup.c =================================================================== --- cfgcleanup.c (revision 169285) +++ cfgcleanup.c (working copy) @@ -2341,8 +2341,7 @@ try_optimize_cfg (int mode) } } delete_basic_block (b); - if (!(mode & CLEANUP_CFGLAYOUT)) - changed = true; + changed = true; /* Avoid trying to remove ENTRY_BLOCK_PTR. */ b = (c == ENTRY_BLOCK_PTR ? c->next_bb : c); continue;