From patchwork Wed Apr 22 13:11:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1275009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=rGSk5imf; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 496gnc0PJyz9sSh for ; Wed, 22 Apr 2020 23:12:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53B96387FC02; Wed, 22 Apr 2020 13:11:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53B96387FC02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587561119; bh=M1Og1kLkUYc7eVg7kuWmpdpxJ1moRq2fG0jipT6g0a0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rGSk5imfzNMsCqHAClsvdYJXlucnLcVXugiXRBnfyicb71kNmrSSR+xnM48EBOg90 TZGO+71n6XDXAttWiUnBkIkjFs4iAbmbNiMIpCucgA6Dp38OeBGz5OR1NVmovxuo+4 ycbsqzsJPkHZpuVutGVcGYwpjZhTk9qwRsQvPPKg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 01D65386F82E for ; Wed, 22 Apr 2020 13:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 01D65386F82E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-_UubPIZVOTKpXmUWQQMaOA-1; Wed, 22 Apr 2020 09:11:55 -0400 X-MC-Unique: _UubPIZVOTKpXmUWQQMaOA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2164E100960F; Wed, 22 Apr 2020 13:11:54 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-104.ams2.redhat.com [10.36.112.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A872B6084A; Wed, 22 Apr 2020 13:11:52 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 03MDBor7019322; Wed, 22 Apr 2020 15:11:50 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 03MDBmQM019321; Wed, 22 Apr 2020 15:11:48 +0200 Date: Wed, 22 Apr 2020 15:11:48 +0200 To: Segher Boessenkool , David Edelsohn Subject: [PATCH] rs6000: Fix C++14 vs. C++17 ABI bug on powerpc64le [PR94707] Message-ID: <20200422131148.GK2424@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! As mentioned in the PR and on IRC, the recently added struct-layout-1.exp new tests FAIL on powerpc64le-linux (among other targets). FAIL: tmpdir-g++.dg-struct-layout-1/t032 cp_compat_x_tst.o-cp_compat_y_tst.o execute FAIL: tmpdir-g++.dg-struct-layout-1/t058 cp_compat_x_tst.o-cp_compat_y_tst.o execute FAIL: tmpdir-g++.dg-struct-layout-1/t059 cp_compat_x_tst.o-cp_compat_y_tst.o execute in particular. The problem is that the presence or absence of the C++17 artificial empty base fields, which have non-zero TYPE_SIZE, but zero DECL_SIZE, change the ABI decisions, if it is present (-std=c++17), the type might not be considered homogeneous, while if it is absent (-std=c++14), it can be. The following patch fixes that and emits a -Wpsabi inform; perhaps more often than it could, because the fact that rs6000_discover_homogeneous_aggregate returns true when it didn't in in GCC 7/8/9 with -std=c++17 doesn't still mean it will make a different ABI decision, but the warning triggered only on the test I've changed (the struct-layout-1.exp tests use -w -Wno-psabi already). Bootstrapped/regtested on powerpc64le-linux, bootstrapped on powerpc64-linux where regtest is still pending, but homogeneous aggregates are an ELFv2 thing, so I don't expect it to change anything (and so far no such messages appear in the testsuite log files). Ok for trunk? 2020-04-22 Jakub Jelinek PR target/94707 * config/rs6000/rs6000-call.c (rs6000_aggregate_candidate): Add CXX17_EMPTY_BASE_SEEN argument. Pass it to recursive calls. Ignore cxx17_empty_base_field_p fields after setting *CXX17_EMPTY_BASE_SEEN to true. (rs6000_discover_homogeneous_aggregate): Adjust rs6000_aggregate_candidate caller. With -Wpsabi, diagnose homogeneous aggregates with C++17 empty base fields. * g++.dg/tree-ssa/pr27830.C: Use -Wpsabi -w for -std=c++17 and higher. Jakub --- gcc/config/rs6000/rs6000-call.c.jj 2020-03-30 22:53:40.746640328 +0200 +++ gcc/config/rs6000/rs6000-call.c 2020-04-22 13:05:07.947809888 +0200 @@ -5528,7 +5528,8 @@ const struct altivec_builtin_types altiv sub-tree. */ static int -rs6000_aggregate_candidate (const_tree type, machine_mode *modep) +rs6000_aggregate_candidate (const_tree type, machine_mode *modep, + bool *cxx17_empty_base_seen) { machine_mode mode; HOST_WIDE_INT size; @@ -5598,7 +5599,8 @@ rs6000_aggregate_candidate (const_tree t || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) return -1; - count = rs6000_aggregate_candidate (TREE_TYPE (type), modep); + count = rs6000_aggregate_candidate (TREE_TYPE (type), modep, + cxx17_empty_base_seen); if (count == -1 || !index || !TYPE_MAX_VALUE (index) @@ -5636,7 +5638,14 @@ rs6000_aggregate_candidate (const_tree t if (TREE_CODE (field) != FIELD_DECL) continue; - sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep); + if (cxx17_empty_base_field_p (field)) + { + *cxx17_empty_base_seen = true; + continue; + } + + sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep, + cxx17_empty_base_seen); if (sub_count < 0) return -1; count += sub_count; @@ -5669,7 +5678,8 @@ rs6000_aggregate_candidate (const_tree t if (TREE_CODE (field) != FIELD_DECL) continue; - sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep); + sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep, + cxx17_empty_base_seen); if (sub_count < 0) return -1; count = count > sub_count ? count : sub_count; @@ -5710,7 +5720,9 @@ rs6000_discover_homogeneous_aggregate (m && AGGREGATE_TYPE_P (type)) { machine_mode field_mode = VOIDmode; - int field_count = rs6000_aggregate_candidate (type, &field_mode); + bool cxx17_empty_base_seen = false; + int field_count = rs6000_aggregate_candidate (type, &field_mode, + &cxx17_empty_base_seen); if (field_count > 0) { @@ -5725,6 +5737,17 @@ rs6000_discover_homogeneous_aggregate (m *elt_mode = field_mode; if (n_elts) *n_elts = field_count; + if (cxx17_empty_base_seen && warn_psabi) + { + static const_tree last_reported_type; + if (type != last_reported_type) + { + inform (input_location, + "prior to GCC 10, parameters of type " + "%qT were passed incorrectly for C++17", type); + last_reported_type = type; + } + } return true; } } --- gcc/testsuite/g++.dg/tree-ssa/pr27830.C.jj 2020-01-11 16:31:54.844296359 +0100 +++ gcc/testsuite/g++.dg/tree-ssa/pr27830.C 2020-04-22 15:01:37.949881630 +0200 @@ -1,5 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O" } */ +/* Ignore ABI warnings for C++17 and later. */ +/* { dg-additional-options "-Wno-psabi -w" { target c++17 } } */ struct gc{}; struct transform:public gc