From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 110FF3858D28 for ; Tue, 31 Jan 2023 12:48:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 110FF3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675169290; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=aZOri+aVSzTGCSLvYBIWnlTwAZAWFRn159uN1aMbqeg=; b=hdbQsTNckOfqAn1eCLG/wghtdMbd2qFH4lHycpXQL8/DvatL7ixYmFL0qcj8L8kmf4aqCC uHrG+gQu/FgNERnwkAtal4AxBe9cpDvL9kwrvNmIPQgSQLjzqMJGA3N4Mf9kipgo66eLnn /DqkcU0cJeSLgjX7brWryF40rM4Ob4Q= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-JlXPgNyIP3G0Sl1gkMh7Gg-1; Tue, 31 Jan 2023 07:48:07 -0500 X-MC-Unique: JlXPgNyIP3G0Sl1gkMh7Gg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C14693815F66; Tue, 31 Jan 2023 12:48:03 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAB5E175A2; Tue, 31 Jan 2023 12:47:56 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30VCleln1046002 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 31 Jan 2023 13:47:54 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30VCksSo1045995; Tue, 31 Jan 2023 13:46:54 +0100 Date: Tue, 31 Jan 2023 13:46:54 +0100 From: Jakub Jelinek To: Siddhesh Poyarekar Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/2] tree-object-size: More consistent behaviour with flex arrays Message-ID: Reply-To: Jakub Jelinek References: <20221221222554.4141678-1-siddhesh@gotplt.org> <20221221222554.4141678-3-siddhesh@gotplt.org> MIME-Version: 1.0 In-Reply-To: <20221221222554.4141678-3-siddhesh@gotplt.org> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.8 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Dec 21, 2022 at 05:25:54PM -0500, Siddhesh Poyarekar wrote: > The tree object size pass tries to fail when it detects a flex array in > the struct, but it ends up doing the right thing only when the flex > array is in the outermost struct. For nested cases (such as arrays > nested in a union or an inner struct), it ends up taking whatever value > the flex array is declared with, using zero for the standard flex array, > i.e. []. > > Rework subobject size computation to make it more consistent across the > board, honoring -fstrict-flex-arrays. With this change, any array at > the end of the struct will end up causing __bos to use the allocated > value of the outer object, bailing out in the maximum case when it can't > find it. In the minimum case, it will return the subscript value or the > allocated value of the outer object, whichever is larger. I think it is way too late in the GCC 13 cycle to change behavior here except for when -fstrict-flex-arrays is used. Plus, am not really convinced it is a good idea to change the behavior here except for the new options, programs in the wild took 2+ years to acommodate for what we GCC requiring and am not sure they'd be willing to be adjusted again. > gcc/ChangeLog: > > PR tree-optimization/107952 > * tree-object-size.cc (size_from_objects): New function. > (addr_object_size): Call it. Fully rely on > array_ref_flexible_size_p call to determine flex array. Jakub