From patchwork Mon May 26 18:20:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 352601 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 58BE314009E for ; Tue, 27 May 2014 04:20:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=a9vOtlgcOCna6EDMvTZ7aGPYn22QK84etJyrbDAW/E9GGdv/n16/k EX2sNUn9UV3AFX99B7Qz2h5lcmMa69vJdTUYZT+BN1DGa9eRQUS4my+KN/GauCL2 YeC5QVshrl5hc5nPSpXtNQIv7qRe1ceiDKB5BBiv38t2//81so07jY= 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:date :from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=Xb9R8chN4KYRtHR6DdFK7weYrtQ=; b=AmnpmGKuKlekk+Habto+phSD7aJn pbZ6TzxtWp7IhTfQnFviZ3NrR/V/xJgiz9VCG5vcCpIBo+kYI25J8/QTxdseXkgR r5Jgcy3T/wVzTzSxgt531o9OfgbOLMYg+XQ27Jpirsn2Yt0NzMQpNwtEXSpAUzEk 19b2xNM4rgb6QSU= Received: (qmail 14716 invoked by alias); 26 May 2014 18:20:40 -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 14701 invoked by uid 89); 26 May 2014 18:20:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx5-phx2.redhat.com Received: from mx5-phx2.redhat.com (HELO mx5-phx2.redhat.com) (209.132.183.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 May 2014 18:20:38 +0000 Received: from zmail14.collab.prod.int.phx2.redhat.com (zmail14.collab.prod.int.phx2.redhat.com [10.5.83.16]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4QIKb9o019784; Mon, 26 May 2014 14:20:37 -0400 Date: Mon, 26 May 2014 14:20:36 -0400 (EDT) From: Kai Tietz To: Jeff Law Cc: "H.J. Lu" , GCC Patches , Richard Henderson Message-ID: <777706000.8424762.1401128436051.JavaMail.zimbra@redhat.com> In-Reply-To: <537F8DC7.3090906@redhat.com> References: <356718653.5712706.1400794422397.JavaMail.zimbra@redhat.com> <537F8DC7.3090906@redhat.com> Subject: Re: [patch i386]: Expand sibling-tail-calls via accumulator register MIME-Version: 1.0 X-IsSubscribed: yes Hi, adjusted patch to make it more bullet-proved and tested it. 2014-05-26 Kai Tietz * config/i386/i386.c (ix86_expand_call): Enforce for sibcalls on memory the use of accumulator-register. (ix86_function_ok_for_sibcall): Reject for x86_64 ABI sibling calls for varardic-functions. Regression tested for x86_64-unknown-linux-gnu, x86_64-w64-mingw32, and i686-pc-cygwin. Ok for apply? Regards, Kai Index: i386.c =================================================================== --- i386.c (revision 210936) +++ i386.c (working copy) @@ -5298,6 +5298,12 @@ ix86_function_ok_for_sibcall (tree decl, tree exp) decl_or_type = type; } + /* We need to reject stdarg-function for x86_64 ABI as accumulator + is used as argument. */ + if (TARGET_64BIT && stdarg_p (type) + && ix86_function_type_abi (type) == SYSV_ABI) + return false; + /* Check that the return value locations are the same. Like if we are returning floats on the 80387 register stack, we cannot make a sibcall from a function that doesn't return a float to a @@ -24916,8 +24922,19 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx call ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode) : !call_insn_operand (XEXP (fnaddr, 0), word_mode)) { + rtx r; fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1); - fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr)); + if (!sibcall) + r = copy_to_mode_reg (word_mode, fnaddr); + else + { + r = gen_rtx_REG (word_mode, AX_REG); + if (! general_operand (fnaddr, VOIDmode)) + fnaddr = force_operand (fnaddr, r); + if (fnaddr != r) + emit_move_insn (r, fnaddr); + } + fnaddr = gen_rtx_MEM (QImode, r); } call = gen_rtx_CALL (VOIDmode, fnaddr, callarg1);