From patchwork Tue Jun 21 20:54:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 101365 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 B4F24B6F88 for ; Wed, 22 Jun 2011 06:55:07 +1000 (EST) Received: (qmail 29517 invoked by alias); 21 Jun 2011 20:55:06 -0000 Received: (qmail 29508 invoked by uid 22791); 21 Jun 2011 20:55:06 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 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; Tue, 21 Jun 2011 20:54:51 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id AD06BCB0232; Tue, 21 Jun 2011 22:54:49 +0200 (CEST) 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 ZSIK9uhIMo54; Tue, 21 Jun 2011 22:54:46 +0200 (CEST) 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 86592CB0359; Tue, 21 Jun 2011 22:54:45 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix ACATS c94007a on 4.6 branch for SPARC64/Solaris Date: Tue, 21 Jun 2011 22:54:49 +0200 User-Agent: KMail/1.9.9 Cc: Jakub Jelinek MIME-Version: 1.0 Message-Id: <201106212254.49936.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 the failure of ACATS c94007a at -O2 on SPARC64/Solaris: the compiler generates wrong code because of a delay slot scheduling (reorg.c) bug. This is a regression on the 4.6 branch (4.5 branch and mainline are clean). fill_simple_delay_slots decides to fill the delay slot of a call insn with another insn that is located about one hundred insns downstream(!); this is a long sequence of call insns that can throw with handlers that fall thru, a typical pattern of ACATS tests, without any intervening jumps or labels. The problem is that fill_simple_delay_slots hoists the insn above such a call that throws and whose handler falls thru, which makes it effectively a jump with edges in the CFG. The code handles the regular jump case: /* Stop our search when seeing an unconditional jump. */ if (JUMP_P (trial_delay)) break; but overlooks this special jump case. This is a known pattern, whose solution has been factored into stop_search_p: /* Return TRUE if this insn should stop the search for insn to fill delay slots. LABELS_P indicates that labels should terminate the search. In all cases, jumps terminate the search. */ static int stop_search_p (rtx insn, int labels_p) { if (insn == 0) return 1; /* If the insn can throw an exception that is caught within the function, it may effectively perform a jump from the viewpoint of the function. Therefore act like for a jump. */ if (can_throw_internal (insn)) return 1; fill_simple_delay_slots already uses stop_search_p for the backward scan. The fix is simply to make it use stop_search_p for the forward scan as well. Bootstrappeg/regtested on SPARC/Solaris and SPARC64/Solaris. 2011-06-21 Eric Botcazou * reorg.c (fill_simple_delay_slots): Use stop_search_p to stop the forward scan as well. Index: reorg.c =================================================================== --- reorg.c (revision 175090) +++ reorg.c (working copy) @@ -2152,7 +2152,7 @@ fill_simple_delay_slots (int non_jumps_p /* This must be an INSN or CALL_INSN. */ pat = PATTERN (trial); - /* USE and CLOBBER at this level was just for flow; ignore it. */ + /* Stand-alone USE and CLOBBER are just for flow. */ if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER) continue; @@ -2271,15 +2271,12 @@ fill_simple_delay_slots (int non_jumps_p } if (target == 0) - for (trial = next_nonnote_insn (insn); trial; trial = next_trial) + for (trial = next_nonnote_insn (insn); !stop_search_p (trial, 1); + trial = next_trial) { next_trial = next_nonnote_insn (trial); - if (LABEL_P (trial) - || BARRIER_P (trial)) - break; - - /* We must have an INSN, JUMP_INSN, or CALL_INSN. */ + /* This must be an INSN or CALL_INSN. */ pat = PATTERN (trial); /* Stand-alone USE and CLOBBER are just for flow. */ @@ -2293,7 +2290,7 @@ fill_simple_delay_slots (int non_jumps_p else trial_delay = trial; - /* Stop our search when seeing an unconditional jump. */ + /* Stop our search when seeing a jump. */ if (JUMP_P (trial_delay)) break;