From patchwork Sun Jan 8 13:51:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 134912 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 D2568B6F71 for ; Mon, 9 Jan 2012 00:52:34 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326635556; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=KvxbTclTE5weV2dRdNYrJRto1og=; b=Daf3Ig4iv57luiI whyIfujX1hxRs1ydU/reqXcxidoRIzxuHqoTaX4DJymRMPwEXVxObbS6R7UeJvKl 4UjOGlLzXtv4Lwr5PzFqKYyMhBlAapJsC6RbQ9NiDcq3fPIPVytCXurstZGVj2UZ 8Y4CHmWf1DX20J+Q/0fBiK9BXPYI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=G9Piea3SzMZgLCu80kBx+s0bQrh5sm6A+bd3Psq2s/BiRbBDaUWPTpNQ1T8NdM UQmIXAtxl5jqtXQWzqWNCJE8YCmgQmPa9SFPAuP3+UTfHZX0jmjUgFkQhAudyHEO ax54vohhywFv6mg8wG48++tevbArLITiuwXuH1IvWb0Bo=; Received: (qmail 5264 invoked by alias); 8 Jan 2012 13:52:30 -0000 Received: (qmail 5256 invoked by uid 22791); 8 Jan 2012 13:52:29 -0000 X-SWARE-Spam-Status: No, hits=-1.8 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; Sun, 08 Jan 2012 13:52:15 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RjtAT-000342-UF from Tom_deVries@mentor.com ; Sun, 08 Jan 2012 05:52:13 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 8 Jan 2012 05:52:04 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Sun, 8 Jan 2012 13:52:11 +0000 Message-ID: <4F099F7E.10904@mentor.com> Date: Sun, 8 Jan 2012 14:51:58 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16 MIME-Version: 1.0 To: Andrew Pinski , Jeff Law CC: "gcc-patches@gcc.gnu.org" , Richard Henderson Subject: [PATCH] PR51471. Don't speculate frame-related insns during delayed branch scheduling. 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 Jeff, this patch fixes PR51471. It prevents frame-related insns from being speculated by delayed branch scheduling, which may cause inconsistencies in cfi state. For one of the examples from PR51471: 20040811-1.c, the scenario is as follows. Before delayed branch scheduling, 20040811-1.c.220r.vartrack: ... (jump_insn:TI 82 77 93 3 (set (pc) (if_then_else (ne (reg/v:SI 3 $3 [orig:210 nD.1374 ] [210]) (reg:SI 7 $7 [255])) (label_ref:SI 30) (pc))) 20040811-1.c:16 434 {*branch_equalitysi} (expr_list:REG_EQUAL (if_then_else (ne (reg/v:SI 3 $3 [orig:210 nD.1374 ] [210]) (const_int 1000000 [0xf4240])) (label_ref:SI 30) (pc)) (expr_list:REG_BR_PROB (const_int 9899 [0x26ab]) (nil))) -> 30) (note 93 82 133 4 [bb 4] NOTE_INSN_BASIC_BLOCK) (note 133 93 122 4 NOTE_INSN_EPILOGUE_BEG) (insn 122 133 123 4 (clobber (mem/c:BLK (reg/f:SI 29 $sp) [4 A8])) 20040811-1.c:19 -1 (nil)) (insn/f:TI 123 122 148 4 (set (reg/f:SI 29 $sp) (reg/f:SI 30 $fp)) 20040811-1.c:19 280 {*movsi_internal} (expr_list:REG_CFA_DEF_CFA (plus:SI (reg/f:SI 29 $sp) (const_int 32 [0x20])) (nil))) ... After delayed branch scheduling, 20040811-1.c.221r.mach: ... (insn 153 77 93 (sequence [ (jump_insn:TI 82 77 123 (set (pc) (if_then_else (ne (reg/v:SI 3 $3 [orig:210 nD.1374 ] [210]) (reg:SI 7 $7 [255])) (label_ref:SI 30) (pc))) 20040811-1.c:16 434 {*branch_equalitysi} (expr_list:REG_BR_PRED (const_int 14 [0xe]) (expr_list:REG_EQUAL (if_then_else (ne (reg/v:SI 3 $3 [orig:210 nD.1374 ] [210]) (const_int 1000000 [0xf4240])) (label_ref:SI 30) (pc)) (expr_list:REG_BR_PROB (const_int 9899 [0x26ab]) (nil)))) -> 30) (insn/f:TI 123 82 93 (set (reg/f:SI 29 $sp) (reg/f:SI 30 $fp)) 280 {*movsi_internal} (expr_list:REG_CFA_DEF_CFA (plus:SI (reg/f:SI 29 $sp) (const_int 32 [0x20])) (nil))) ]) 20040811-1.c:16 -1 (nil)) (note 93 153 133 [bb 4] NOTE_INSN_BASIC_BLOCK) (note 133 93 122 NOTE_INSN_EPILOGUE_BEG) (insn 122 133 148 (clobber (mem/c:BLK (reg/f:SI 29 $sp) [4 A8])) 20040811-1.c:19 -1 (nil)) ... Frame-related insn 123 is moved into the delay slot of jump 82. This speculatively executes the insn 123 before the jump to code_label 30, which causes an inconsistent cfi state at code_label 30, which causes the following ICE: ... 20040811-1.c: In function 'main': 20040811-1.c:19:1: internal compiler error: in maybe_record_trace_start, at dwarf2cfi.c:2231 ... this patch prevents frame-related insns from being speculated by delayed branch scheduling, fixing this ICE. build & reg-tested on mips64el-linux-gnu. Andrew, did you get to do bootstrap/test on mips64-linux-gnu? Jeff, ok for trunk? Thanks, - Tom 2012-01-08 Tom de Vries Andrew Pinski * reorg.c (fill_slots_from_thread): Don't speculate frame-related insns. Index: gcc/reorg.c =================================================================== --- gcc/reorg.c (revision 182903) +++ gcc/reorg.c (working copy) @@ -2716,7 +2716,8 @@ fill_slots_from_thread (rtx insn, rtx co if (!must_annul && (condition == const_true_rtx || (! insn_sets_resource_p (trial, &opposite_needed, true) - && ! may_trap_or_fault_p (pat)))) + && ! may_trap_or_fault_p (pat) + && ! RTX_FRAME_RELATED_P (trial)))) { old_trial = trial; trial = try_split (pat, trial, 0);