From patchwork Sat Feb 13 08:54:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 582376 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DEEA614056B for ; Sat, 13 Feb 2016 19:54:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Nsy2z42G; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; q= dns; s=default; b=U8kxcidQxPJqfII3joj9/nwWPwbFZRAkBl38CAX+zaxDKc I+HAfVR4iZPtrm8aIlN4o+HYdGab19+cgh5oIie+be1NfDq3zjzAbKqtpJt91Rqy YHdnhNzPDN7q7/CPIv9I0zZkVRj4BPSXwpvTD+o78slncG8+C5W11iDeI7/Do= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; s= default; bh=lMXStmv+uJHv1tNY7iv3WPp8df0=; b=Nsy2z42GQW0o1QO4+0iL Krt2aFdAD519EqD4bdzjuLVCUbQrVh/8eMToRlT5sEpmYuk5C6xb171Gw8YQPVMT FdqvwahyfddXr+nBoE89frrQzLfkV0zjURSETHmbw3IFzhGNp4Cl0qxbRriyJto+ mHwq4dOOKa38POSVQT7hkY8= Received: (qmail 103085 invoked by alias); 13 Feb 2016 08:54:48 -0000 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 Received: (qmail 103048 invoked by uid 89); 13 Feb 2016 08:54:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.4 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=shsim, mb, -m4, mlm2, ml, -m4a X-HELO: mailout04.t-online.de Received: from mailout04.t-online.de (HELO mailout04.t-online.de) (194.25.134.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 13 Feb 2016 08:54:46 +0000 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout04.t-online.de (Postfix) with SMTP id 79D9E15B243 for ; Sat, 13 Feb 2016 09:54:42 +0100 (CET) Received: from [192.168.0.16] (G0vEG8ZGghjI0flJhXRuF3BrNs1Rzmk0FckRTq+k+Bgs+aqvUD6eqczXlBv2OwRZWq@[115.165.93.200]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1aUVyP-1eX2dk0; Sat, 13 Feb 2016 09:54:37 +0100 Message-ID: <1455353674.2124.260.camel@t-online.de> Subject: [SH][committed] Fix PR 67260 From: Oleg Endo To: gcc-patches Date: Sat, 13 Feb 2016 17:54:34 +0900 Mime-Version: 1.0 X-IsSubscribed: yes Hi, The attached patch(es) fix PR 67260. For details please see the discussion in the PR log. Tested on trunk and sh-elf with make -k check RUNTESTFLAGS="--target_board=sh-sim\{-m2/-ml,-m2/-mb, -m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" and on GCC 5 and GCC 4.9 branch with make all-gcc and compiling the testcase. Committed to trunk as r233399 + r233400, to GCC 5 branch as r233401 and to GCC 4.9 branch as r233402. Cheers, Oleg Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 233397) +++ gcc/config/sh/sh.md (working copy) @@ -10476,12 +10476,16 @@ (const_string "single") (const_string "double"))) (set_attr "type" "jump_ind")]) +;; sibcall_value_pcrel used to have a =&k clobber for the scratch register +;; that it needs for the branch address. This causes troubles when there +;; is a big overlap of argument and return value registers. Hence, use a +;; fixed call clobbered register for the address. See also PR 67260. (define_insn_and_split "sibcall_value_pcrel" [(set (match_operand 0 "" "=rf") (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "")) (match_operand 2 "" ""))) (use (reg:SI FPSCR_MODES_REG)) - (clobber (match_scratch:SI 3 "=&k")) + (clobber (reg:SI R1_REG)) (return)] "TARGET_SH2 && !TARGET_FDPIC" "#" @@ -10491,6 +10495,8 @@ rtx lab = PATTERN (gen_call_site ()); rtx call_insn; + operands[3] = gen_rtx_REG (SImode, R1_REG); + sh_expand_sym_label2reg (operands[3], operands[1], lab, true); call_insn = emit_call_insn (gen_sibcall_valuei_pcrel (operands[0], operands[3], @@ -10505,6 +10511,8 @@ (const_string "single") (const_string "double"))) (set_attr "type" "jump_ind")]) +;; Like for sibcall_value_pcrel, use a fixed call clobbered register for +;; the branch address. (define_insn_and_split "sibcall_value_pcrel_fdpic" [(set (match_operand 0 "" "=rf") (call (mem:SI (match_operand:SI 1 "symbol_ref_operand")) @@ -10511,7 +10519,7 @@ (match_operand 2))) (use (reg:SI FPSCR_MODES_REG)) (use (reg:SI PIC_REG)) - (clobber (match_scratch:SI 3 "=k")) + (clobber (reg:SI R1_REG)) (return)] "TARGET_SH2 && TARGET_FDPIC" "#" @@ -10520,6 +10528,8 @@ { rtx lab = PATTERN (gen_call_site ()); + operands[3] = gen_rtx_REG (SImode, R1_REG); + sh_expand_sym_label2reg (operands[3], operands[1], lab, true); rtx i = emit_call_insn (gen_sibcall_valuei_pcrel_fdpic (operands[0], operands[3], Index: gcc/testsuite/gcc.target/sh/torture/pr67260.c =================================================================== --- gcc/testsuite/gcc.target/sh/torture/pr67260.c (revision 0) +++ gcc/testsuite/gcc.target/sh/torture/pr67260.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-additional-options "-std=gnu99 -fPIC" } */ +/* { dg-do compile } */ + +#pragma GCC visibility push(hidden) + +double _Complex foo (double _Complex arg); + +double _Complex +bar (double _Complex arg) +{ + return foo (arg); +}