From patchwork Mon Mar 9 16:07:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yvan Roux X-Patchwork-Id: 45550 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3EE9920285 for ; Mon, 9 Mar 2015 16:07:59 +0000 (UTC) Received: by wesu56 with SMTP id u56sf5354251wes.2 for ; Mon, 09 Mar 2015 09:07:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-original-sender :x-original-authentication-results; bh=pVexuyjCn5EVQogHAkK9XFjagwk5hQcFrjxfX5MWlOc=; b=hvHZaxocw9GHY3UdSYGd5qYHdIhSgAF1wpZQQff4XFNJL1mo5hX7YdzkeHMcIl90b0 u0SXorju9iU8ePTVJh+KLsh4+GNA9+VfQRaK16Mqt9oiGvv/jnLzIOMiX8S4U7bOWEz0 R08gAuzWKX6UXmxhbr5BnZdY6eKOy0vDAm7MB8CLd5HHlA/Yq/ffnWhIJmM7Xt1kPLDz KcbyNVtLzltICi786zDWGSMWH1W4+6cD4DsuFDQZ6Vtizhl4hEqWZi6I/XutzEvuuH/3 OpuiYCgk5sUOiP2Hu0Lw0rJNBBJmMR06j5aUU+g9QQwvJ8WpJ2vsJPtADPuZitZvNXL3 6XrQ== X-Gm-Message-State: ALoCoQlSzSyyaRESn3DPy6o1UQ2ZjUKZrH5qVS+vMvIbCFsTh/uFfQfIKG1dXbXN6x05SirbpXTz X-Received: by 10.152.164.171 with SMTP id yr11mr1149769lab.4.1425917278041; Mon, 09 Mar 2015 09:07:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.164.193 with SMTP id ys1ls338750lab.39.gmail; Mon, 09 Mar 2015 09:07:57 -0700 (PDT) X-Received: by 10.152.5.194 with SMTP id u2mr26656718lau.88.1425917277893; Mon, 09 Mar 2015 09:07:57 -0700 (PDT) Received: from mail-la0-x22a.google.com (mail-la0-x22a.google.com. [2a00:1450:4010:c03::22a]) by mx.google.com with ESMTPS id p2si14623980lag.109.2015.03.09.09.07.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2015 09:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22a as permitted sender) client-ip=2a00:1450:4010:c03::22a; Received: by labge10 with SMTP id ge10so4900988lab.7 for ; Mon, 09 Mar 2015 09:07:57 -0700 (PDT) X-Received: by 10.112.212.106 with SMTP id nj10mr7915847lbc.36.1425917277738; Mon, 09 Mar 2015 09:07:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1576659lbj; Mon, 9 Mar 2015 09:07:56 -0700 (PDT) X-Received: by 10.70.88.172 with SMTP id bh12mr37490601pdb.52.1425917275498; Mon, 09 Mar 2015 09:07:55 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id hv8si31523387pad.13.2015.03.09.09.07.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2015 09:07:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-393238-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 34135 invoked by alias); 9 Mar 2015 16:07:41 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 34120 invoked by uid 89); 9 Mar 2015 16:07:40 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f53.google.com Received: from mail-oi0-f53.google.com (HELO mail-oi0-f53.google.com) (209.85.218.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 09 Mar 2015 16:07:39 +0000 Received: by oiba3 with SMTP id a3so30174960oib.7 for ; Mon, 09 Mar 2015 09:07:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.219.215 with SMTP id s206mr20868217oig.114.1425917257288; Mon, 09 Mar 2015 09:07:37 -0700 (PDT) Received: by 10.202.221.214 with HTTP; Mon, 9 Mar 2015 09:07:37 -0700 (PDT) In-Reply-To: <20150206203709.GA22441@kam.mff.cuni.cz> References: <20150206202331.GO1746@tucnak.redhat.com> <20150206203709.GA22441@kam.mff.cuni.cz> Date: Mon, 9 Mar 2015 17:07:37 +0100 Message-ID: Subject: Re: [PATCH] Fix thunk expansion (PR ipa/64896) From: Yvan Roux To: Jan Hubicka Cc: Jakub Jelinek , Richard Biener , "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes X-Original-Sender: yvan.roux@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22a as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, As added in the PR, this issue is also present on 4.9 branch and affects at least arm-linux-gnueabihf target (as reported in PR61207). I've backported it in the 4.9 branch with the attached patch. The difference with the trunk code is due the code introduced by PR63587 fix (I didn't checked on power7, on which the PR was initially reported, but I didn't managed to reproduce the issue for arm targets on 4.9 branch). Boostrapped on x86_64, and tested on arm/aarch64 targets (regression testing is ongoing). is ok for 4.9 branch when validation is done ? Thanks Yvan gcc/ 2015-03-09 Yvan Roux Backport from trunk r220489. 2015-02-06 Jakub Jelinek PR ipa/64896 * cgraphunit.c (cgraph_node::expand_thunk): If restype is not is_gimple_reg_type nor the thunk_fndecl returns aggregate_value_p, set restmp to a temporary variable instead of resdecl. gcc/testsuite/ 2015-03-09 Yvan Roux Backport from trunk r220489. 2015-02-06 Jakub Jelinek PR ipa/64896 * g++.dg/ipa/pr64896.C: New test. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 8f57607..130fc0d 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1572,9 +1572,14 @@ expand_thunk (struct cgraph_node *node, bool output_asm_thunks) restmp = gimple_fold_indirect_ref (resdecl); else if (!is_gimple_reg_type (restype)) { - restmp = resdecl; - add_local_decl (cfun, restmp); - BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; + if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl))) + { + restmp = resdecl; + add_local_decl (cfun, restmp); + BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; + } + else + restmp = create_tmp_var (restype, "retval"); } else restmp = create_tmp_reg (restype, "retval"); diff --git a/gcc/testsuite/g++.dg/ipa/pr64896.C b/gcc/testsuite/g++.dg/ipa/pr64896.C new file mode 100644 index 0000000..0a78220 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64896.C @@ -0,0 +1,29 @@ +// PR ipa/64896 +// { dg-do compile } +// { dg-options "-O2" } + +struct A { int a, b; }; +struct B { A c; int d; }; +struct C { virtual B fn1 () const; }; +struct D { B fn2 () const; int fn3 () const; C *fn4 () const; }; + +int +D::fn3 () const +{ + fn4 ()->fn1 (); +} + +B +D::fn2 () const +{ + return B (); +} + +class F : C +{ + B + fn1 () const + { + return B (); + } +};