From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 305503858D39 for ; Mon, 23 Oct 2023 12:37:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 305503858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 305503858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698064664; cv=none; b=wiyXK6P9HRUEOqNjup7JeAVU+J84Nn7meonUONQaxUQa6oCmDlNDopl62lcVEiNHWzEY2ne8p2L9jrK4r6go5mnDCuyB4iB/20zOOIyTRvOYh+5I7noY3cVFbUrpe7KBtl7YfMAdALa1Vf4bPiwIqRsQKoD6PYynNq0L4ZAZCKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698064664; c=relaxed/simple; bh=iS/1I3csgnnPEpwn1f1FjETziSwr5TCRS+hllwtV6ws=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=HyeiOwjf6691qcabmeZvwn98n/37mKxR+gVHd5EudN2lAieWwziU9dbRR2NJkcvjMPeQpUYFGrFZFaFlvn9muSi9Pn/G5KjA8vgofYUxlKTlDK15PoZelOgDkJMh1jVJA9COWKJzk88GbyB1dqvAxRc8cKze8a4K7FrOZFIYBUk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-507a5f2193bso3703020e87.1 for ; Mon, 23 Oct 2023 05:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698064660; x=1698669460; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xCYc5uOq3cqATNboZ7HybRwRqhQdJtdWHVesIW6e5Zk=; b=dRlR4d/FPSXoIq46Kk6ecBDaO2PrH40NHY6mniCsAWUrdgF2M56vJolJj8QlEZ6mMW HeX8hV/kydp6wKrdaNkUL3Qy1E1FTgfxZY/ghJaY2oBELnRB6ekpefFRoCFr578y61gv 6CzoRvIxp52SEWz5+hu1qiR1GN2DXwhiXUSnJg3AWmb/qj550lJfEYhj9r+w0wS9ktO+ 1c8WLg0PHTYuzQegEloLZ5yPrn0YbMkkDY1e5kiT1CRktVh5YWo0+H5oBXYHVMJWXW/m xiy0mngmYzR/R1WXjmdLcBbHK7pJyffSghFUniAw9Pd5h7HM3hemtbIIOcua1MLKnYW8 EOaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698064660; x=1698669460; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xCYc5uOq3cqATNboZ7HybRwRqhQdJtdWHVesIW6e5Zk=; b=DNSYM7wlsR+7M+6HKEiVvKlqvmnylC66oG4EtGhAlmWiPAzBJqWJSd5c31gPkXIh8M Q8duiwmQJPXdfecqWOFWw3sH5DWn3gjFjvfjoxH+/X26HQEmdiPUqkT+4b/gpoYGOjE9 DdWPKkjv7KzepE9qNJPkG7Rzup5FTmY7ZgjxSoYtBuXvZ+JlpcZ8BzZ+s8IzNAOcjtWp QXet+pqbpeVUBwCKHF6fP/4ZFbyRve2jsfiGIUK0mynShmJm7lKXH08r0YqzJ3q2FZ+w DxYYayni13AySexoxK1j5IROurtyo6+muRYiFCycerRJ4Ww+3EeavYbAvQ+HtKWxRPcq WS8A== X-Gm-Message-State: AOJu0YwnxnoV/5RUy2ijwcVzoNA/YHBHcLeGORJ4T20+HYoTiC76Z9QE qXCYk0uUSKfAfnHVCo/BVcTk6IqcCZxDIZNMwp8= X-Google-Smtp-Source: AGHT+IGmfY8Xk/5rZdAn6xcRCPy3qzcrsjPGoXhsyBloPlX655wESHDCCPSZLTiuOBqksblHiwjak7Mi2pz8mSt7KDU= X-Received: by 2002:a19:7502:0:b0:503:2879:567 with SMTP id y2-20020a197502000000b0050328790567mr2648405lfe.28.1698064659418; Mon, 23 Oct 2023 05:37:39 -0700 (PDT) MIME-Version: 1.0 References: <22BDBC0E-1B28-46D0-BCA4-588F73B198E0@oracle.com> <46C61773-8C30-4A68-815A-E724A6A4DCEE@oracle.com> <2151D1F7-721B-4DDE-A2A1-B6FCA5F2783F@oracle.com> <3a6cb1b4-05da-e48c-4acc-a1cf3977c74d@gotplt.org> In-Reply-To: <3a6cb1b4-05da-e48c-4acc-a1cf3977c74d@gotplt.org> From: Richard Biener Date: Mon, 23 Oct 2023 14:34:34 +0200 Message-ID: Subject: Re: HELP: Will the reordering happen? Re: [V3][PATCH 0/3] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896) To: Siddhesh Poyarekar Cc: Qing Zhao , Joseph Myers , Jakub Jelinek , gcc Patches , kees Cook , Martin Uecker , "isanbard@gmail.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Mon, Oct 23, 2023 at 1:27=E2=80=AFPM Siddhesh Poyarekar wrote: > > On 2023-10-23 03:57, Richard Biener wrote: > > On Fri, Oct 20, 2023 at 10:41=E2=80=AFPM Qing Zhao wrote: > >> > >> > >> > >>> On Oct 20, 2023, at 3:10 PM, Siddhesh Poyarekar = wrote: > >>> > >>> On 2023-10-20 14:38, Qing Zhao wrote: > >>>> How about the following: > >>>> Add one more parameter to __builtin_dynamic_object_size(), i.e > >>>> __builtin_dynamic_object_size (_1,1,array_annotated->foo)? > >>>> When we see the structure field has counted_by attribute. > >>> > >>> Or maybe add a barrier preventing any assignments to array_annotated-= >foo from being reordered below the __bdos call? Basically an __asm__ with = array_annotated->foo in the clobber list ought to do it I think. > >> > >> Maybe just adding the array_annotated->foo to the use list of the call= to __builtin_dynamic_object_size should be enough? > >> > >> But I am not sure how to implement this in the TREE level, is there a = USE_LIST/CLOBBER_LIST for each call? Then I can just simply add the counte= d_by field =E2=80=9Carray_annotated->foo=E2=80=9D to the USE_LIST of the ca= ll to __bdos? > >> > >> This might be the simplest solution? > > > > If the dynamic object size is derived of a field then I think you need = to > > put the "load" of that memory location at the point (as argument) > > of the __bos call right at parsing time. I know that's awkward because > > you try to play tricks "discovering" that field only late, but that's n= ot > > going to work. > > > > A related issue is that assignment to the field and storage allocation > > are not tied together - if there's no use of the size data we might > > remove the store of it as dead. > > Maybe the trick then is to treat the size data as volatile? That ought > to discourage reordering and also prevent elimination of the "dead" store= ? But we are an optimizing compiler, not a static analysis machine, so I fail to see how this is a useful suggestion. I think Martins suggestion to approach this as a language extension is more useful and would make it easier to handle this? Richard. > Thanks, > Sid