From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27249 invoked by alias); 12 Jan 2012 12:06:48 -0000 Received: (qmail 27238 invoked by uid 22791); 12 Jan 2012 12:06:47 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 12:06:34 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/28831] [4.4/4.5/4.6/4.7 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter Date: Thu, 12 Jan 2012 12:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.4.7 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg01371.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831 --- Comment #12 from Richard Guenther 2012-01-12 12:05:26 UTC --- (In reply to comment #5) > Here's another example: > > struct A { int i[100]; }; > void f(struct A); > int main() > { > f((struct A){1}); > } > > Here we build up the compound literal on the stack and then copy it into the > argument slot. > > This seems to be a problem with GIMPLE, as there's no way to represent that we > want a particular temporary object to live in the argument slot. > > This is both more and less of a problem for C++, as it has many more temporary > struct objects, but also has pass-by-reference (and the ABI does transparent > pass-by-reference for non-POD structs). I suppose it would be easy to add a decl flag DECL_ARGUMENT_SLOT, but of course defering its allocation until we expand the call (if the argument is passed by value) is going to be interesting, as we basically have the argument setup visible in gimple. For your testcase it's passed by reference it seems so that would be ok and we can simply avoid the argument slot allocation and copying at expansion time.