From patchwork Fri Aug 14 06:58:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1344683 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=SI4dMj1N; 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 4BSZ6s2Vhrz9sTr for ; Fri, 14 Aug 2020 16:59:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 183313844030; Fri, 14 Aug 2020 06:59:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 183313844030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597388350; bh=ipPUmjgK+mwTUnqSYruJvCeea/PrPwO4H9c7TUua1uI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=SI4dMj1N/CHdDJOR5A9smnohN4Q0L0vtosUNpqY7+iqcIXA8hCI+XKJhmKOUJOG+8 NdYknXGHcAZJv/TNIOvdH9yX5fj2lhVak0qaVlwIBO9Am0rBzudkI/R93HhdAY82PC t+ixYCo4HpoVKHWaOLBvW3wHCYv2L/2IZ8Iciw4o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 991BF3857C42 for ; Fri, 14 Aug 2020 06:59:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 991BF3857C42 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-404-GiMXaj3_PJOMaSXaKJQHIA-1; Fri, 14 Aug 2020 02:59:05 -0400 X-MC-Unique: GiMXaj3_PJOMaSXaKJQHIA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C74BC1015DBC; Fri, 14 Aug 2020 06:59:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-174.ams2.redhat.com [10.36.113.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9605F5C1A3; Fri, 14 Aug 2020 06:59:02 +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 07E6wwJS017745; Fri, 14 Aug 2020 08:58:58 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 07E6wtkI017744; Fri, 14 Aug 2020 08:58:55 +0200 Date: Fri, 14 Aug 2020 08:58:55 +0200 To: Richard Biener , Jeff Law Subject: [PATCH] vec: Fix bootstrap on i686-linux, 32-bit darwin and AIX Message-ID: <20200814065855.GL2363@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Iain Sandoe , Jonathan Wakely , gcc-patches@gcc.gnu.org, David Edelsohn , Tobias Burnus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! As mentioned earlier, embedded_size is broken on vecs of long long, double etc. on some platforms, which breaks bootstrap. E.g. on i686-linux, the problem is mostly with older GCC versions being used as stage1 compiler (GCC 4.8 to 7.* in particular), because alignas (long long) makes U 64-bit aligned, while when long long m_vecdata[1]; is in vec, it is only 32-bit aligned. We've tried various ways and the following one seems to work, use the old way (offsetof (vec, m_vecdata)) for non-class types as well as standard layout class types, i.e. whenever offsetof is guaranteed to work, and for others use the new day (in that case we don't run into problems with long long or other scalar types and for the structure layout there is just a struct with a given alignment. Bootstrapped/regtested on x86_64-linux and i686-linux, AFAIK Iain and David are bootstrapping/regtesting it on 32-bit darwin and AIX and it got through the spots where it broke before, ok for trunk? 2020-08-14 Jakub Jelinek Jonathan Wakely * system.h: Include type_traits. * vec.h (vec::embedded_size): Use offsetof and asserts on vec_stdlayout, which is conditionally a vec (for standard layout T) and otherwise vec_embedded. Jakub --- gcc/system.h.jj 2020-07-28 15:39:09.984756558 +0200 +++ gcc/system.h 2020-08-13 16:33:48.330642026 +0200 @@ -235,6 +235,7 @@ extern int errno; # include # include # include +# include #endif /* Some of glibc's string inlines cause warnings. Plus we'd rather --- gcc/vec.h.jj 2020-08-13 15:41:17.221755055 +0200 +++ gcc/vec.h 2020-08-13 16:31:42.190367975 +0200 @@ -1283,9 +1283,11 @@ vec::embedded_size (unsi { struct alignas (T) U { char data[sizeof (T)]; }; typedef vec vec_embedded; - static_assert (sizeof (vec_embedded) == sizeof(vec), ""); - static_assert (alignof (vec_embedded) == alignof(vec), ""); - return offsetof (vec_embedded, m_vecdata) + alloc * sizeof (T); + typedef typename std::conditional::value, + vec, vec_embedded>::type vec_stdlayout; + static_assert (sizeof (vec_stdlayout) == sizeof (vec), ""); + static_assert (alignof (vec_stdlayout) == alignof (vec), ""); + return offsetof (vec_stdlayout, m_vecdata) + alloc * sizeof (T); }