From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1205 invoked by alias); 3 Mar 2015 23:59:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1187 invoked by uid 89); 3 Mar 2015 23:59:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mo-sw.iij4u.or.jp Received: from mo-sw1501.iij4u.or.jp (HELO mo-sw.iij4u.or.jp) (210.130.239.241) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 03 Mar 2015 23:59:10 +0000 Received: by mo-sw.iij4u.or.jp (4u-mo-sw1501) id t23Nx6Ou031265; Wed, 4 Mar 2015 08:59:06 +0900 Received: from localhost (132.8.30.125.dy.iij4u.or.jp [125.30.8.132]) by mbox.iij4u.or.jp (4u-mbox1501) id t23Nx5bD028298; Wed, 4 Mar 2015 08:59:05 +0900 Date: Tue, 03 Mar 2015 23:59:00 -0000 Message-Id: <20150304.085904.404249988.kkojima@rr.iij4u.or.jp> To: gcc-patches@gcc.gnu.org Subject: [patch committed SH] Fix PR target/65249 From: Kaz Kojima Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00175.txt.bz2 The attached patches are to fix PR target/65249 which is a 4.9/5 regression. It avoids yet another R0_REGS spill failure with pre-allocating R0 reg in symGOT_load when the loading symbol is __stack_chk_guard. Although the problem went away with -mlra and LRA would be the real fix for this issue, SH is still in transition to LRA and we have no chance for 4.9. Tested with sh4-unknown-linux-gnu on trunk and 4.9 branch. Committed on trunk and 4.9. Regards, kaz -- 2015-03-03 Kaz Kojima PR target/65249 * config/sh/sh.md (symGOT_load): Use R0 reg for operands[2] when called for __stack_chk_guard symbol. [trunk/gcc] diff --git a/config/sh/sh.md b/config/sh/sh.md index 2435ec9..24ddc9e 100644 --- a/config/sh/sh.md +++ b/config/sh/sh.md @@ -10690,10 +10690,26 @@ label: "" { rtx mem; + bool stack_chk_guard_p = false; operands[2] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); operands[3] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); + if (!TARGET_SHMEDIA + && flag_stack_protect + && GET_CODE (operands[1]) == CONST + && GET_CODE (XEXP (operands[1], 0)) == UNSPEC + && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == SYMBOL_REF + && strcmp (XSTR (XVECEXP (XEXP (operands[1], 0), 0, 0), 0), + "__stack_chk_guard") == 0) + stack_chk_guard_p = true; + + /* Use R0 to avoid long R0 liveness which stack-protector tends to + produce. */ + if (! sh_lra_flag + && stack_chk_guard_p && ! reload_in_progress && ! reload_completed) + operands[2] = gen_rtx_REG (Pmode, R0_REG); + if (TARGET_SHMEDIA) { rtx reg = operands[2]; @@ -10721,13 +10737,7 @@ label: insn to avoid combining (set A (plus rX r12)) and (set op0 (mem A)) when rX is a GOT address for the guard symbol. Ugly but doesn't matter because this is a rare situation. */ - if (!TARGET_SHMEDIA - && flag_stack_protect - && GET_CODE (operands[1]) == CONST - && GET_CODE (XEXP (operands[1], 0)) == UNSPEC - && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == SYMBOL_REF - && strcmp (XSTR (XVECEXP (XEXP (operands[1], 0), 0, 0), 0), - "__stack_chk_guard") == 0) + if (stack_chk_guard_p) emit_insn (gen_chk_guard_add (operands[3], operands[2])); else emit_move_insn (operands[3], gen_rtx_PLUS (Pmode, operands[2], [gcc-4_9-branch/gcc] diff --git a/config/sh/sh.md b/config/sh/sh.md index 00bbf3e..f75f5a2 100644 --- a/config/sh/sh.md +++ b/config/sh/sh.md @@ -10164,10 +10164,25 @@ label: "" { rtx mem; + bool stack_chk_guard_p = false; operands[2] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); operands[3] = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); + if (!TARGET_SHMEDIA + && flag_stack_protect + && GET_CODE (operands[1]) == CONST + && GET_CODE (XEXP (operands[1], 0)) == UNSPEC + && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == SYMBOL_REF + && strcmp (XSTR (XVECEXP (XEXP (operands[1], 0), 0, 0), 0), + "__stack_chk_guard") == 0) + stack_chk_guard_p = true; + + /* Use R0 to avoid long R0 liveness which stack-protector tends to + produce. */ + if (stack_chk_guard_p && ! reload_in_progress && ! reload_completed) + operands[2] = gen_rtx_REG (Pmode, R0_REG); + if (TARGET_SHMEDIA) { rtx reg = operands[2]; @@ -10195,13 +10210,7 @@ label: insn to avoid combining (set A (plus rX r12)) and (set op0 (mem A)) when rX is a GOT address for the guard symbol. Ugly but doesn't matter because this is a rare situation. */ - if (!TARGET_SHMEDIA - && flag_stack_protect - && GET_CODE (operands[1]) == CONST - && GET_CODE (XEXP (operands[1], 0)) == UNSPEC - && GET_CODE (XVECEXP (XEXP (operands[1], 0), 0, 0)) == SYMBOL_REF - && strcmp (XSTR (XVECEXP (XEXP (operands[1], 0), 0, 0), 0), - "__stack_chk_guard") == 0) + if (stack_chk_guard_p) emit_insn (gen_chk_guard_add (operands[3], operands[2])); else emit_move_insn (operands[3], gen_rtx_PLUS (Pmode, operands[2],