From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21859 invoked by alias); 3 Jul 2015 14:40:59 -0000 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 Received: (qmail 21805 invoked by uid 48); 3 Jul 2015 14:40:54 -0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/66750] [4.9/5/6] Aggregate return not generated with -m32 -mregparm=3 or with -miamcu Date: Fri, 03 Jul 2015 14:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 6.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-07/txt/msg00273.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66750 H.J. Lu changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-07-03 Ever confirmed|0 |1 --- Comment #1 from H.J. Lu --- We have 'callee_pop_aggregate_return (NUMBER)' On x86-32 targets, you can use this attribute to control how aggregates are returned in memory. If the caller is responsible for popping the hidden pointer together with the rest of the arguments, specify NUMBER equal to zero. If callee is responsible for popping the hidden pointer, specify NUMBER equal to one. The default x86-32 ABI assumes that the callee pops the stack for hidden pointer. However, on x86-32 Microsoft Windows targets, the compiler assumes that the caller pops the stack for hidden pointer. and static int ix86_return_pops_args (tree fundecl, tree funtype, int size) { ... /* Lose any fake structure return argument if it is passed on the stack. */ if (aggregate_value_p (TREE_TYPE (funtype), fundecl) && !ix86_keep_aggregate_return_pointer (funtype)) { int nregs = ix86_function_regparm (funtype, fundecl); if (nregs == 0) return GET_MODE_SIZE (Pmode); } return 0; } For -miamcu and -m64, ix86_return_pops_args always returns 0 since they pass parameters in registers. We have 2 choices: 1. Update IA MCU psABI to follow x86-64 psABI such that callee doesn't pop the stack. 2. Update GCC to always pop stack for -m32. I prefer #1.