From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B5AA3952007; Tue, 28 Apr 2020 14:38:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B5AA3952007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588084738; bh=SIa6BajXwaU5cZ4ZLls0w4chuqQq2Ea7VtTf3m1mq6w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Q54hCkckJcVtxj88dF0NRs5WicqGLcKjh2Uie/V6aJqav6Bs5cn74Gda7JHDQB5pI OS3jYWxgC914xSqfyBQAEr2vj/udyO1rSYC5XS3HAPCryii7h1rhNtk/3XmQ7QnpoN Niyp2VcnmUdiOv4E80GdqI0oo/TL81ES53stiQpw= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94711] [8/9/10 Regression] class with empty base passed incorrectly with -std=c++17 on arm Date: Tue, 28 Apr 2020 14:38:58 +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: 10.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: blocker X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2020 14:38:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94711 --- Comment #2 from CVS Commits --- The master branch has been updated by Matthew Malcomson : https://gcc.gnu.org/g:a5bff8af0a68d039e1586087639c86d6931c9b81 commit r10-8013-ga5bff8af0a68d039e1586087639c86d6931c9b81 Author: Matthew Malcomson Date: Tue Apr 28 15:38:43 2020 +0100 [Arm] Account for C++17 artificial field determining Homogeneous Aggreg= ates In C++14, an empty class deriving from an empty base is not an aggregate, while in C++17 it is. In order to implement this, GCC adds an artificial field to such classes. This artificial field has no mapping to Fundamental Data Types in the Arm PCS ABI and hence should not count towards determining whether an object can be passed using the vector registers as per section "7.1.2 Procedure Calling" in the arm PCS =20=20=20 https://developer.arm.com/docs/ihi0042/latest?_ga=3D2.60211309.1506853196.1= 533541889-405231439.1528186050 This patch avoids counting this artificial field in aapcs_vfp_sub_candidate, and hence calculates whether such objects should be passed in vector registers in the same manner as C++14 (where the artificial field does not exist). Before this change, the test below would pass the arguments to `f` in general registers. After this change, the test passes the arguments to `f` using the vector registers. The new behaviour matches the behaviour of `armclang`, and also matches the GCC behaviour when run with `-std=3Dgnu++14`. > gcc -std=3Dgnu++17 -march=3Darmv8-a+simd -mfloat-abi=3Dhard test.cpp ``` test.cpp struct base {}; struct pair : base { float first; float second; pair (float f, float s) : first(f), second(s) {} }; void f (pair); int main() { f({3.14, 666}); return 1; } ``` We add a `-Wpsabi` warning to catch cases where this fix has changed the ABI for some functions. Unfortunately this warning is not emitted twice for multiple calls to the same function, but I feel this is not much of a problem and can be fixed later if needs be. (i.e. if `main` called `f` twice in a row we only emit a diagnostic for= the first). Testing: Bootstrapped and regression tested on arm-linux. This change fixes the struct-layout-1 tests Jakub added https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544204.html Regression tested on arm-none-eabi. gcc/ChangeLog: 2020-04-28 Matthew Malcomson Jakub Jelinek PR target/94711 * config/arm/arm.c (aapcs_vfp_sub_candidate): Account for C++17 empty base class artificial fields. (aapcs_vfp_is_call_or_return_candidate): Warn when PCS ABI decision is different after this fix.=