On Mon, Sep 15, 2025 at 12:05 PM Eric Botcazou <botca...@adacore.com> wrote:
>
> > Yes please.  Can we assert the MEM_REF offset is zero and the MEM_REF
> > isn't type-punning, aka TREE_TYPE of the MEM_REF is compatible with
> > the decls type, or is this not easily possible (again because of the
> > placeholders)?
>
> Yes for the offset, but no for the type punning because we allow it for these
> types (they have the "may_alias" attribute).
>
> > But the subprogram invocation would be guarded with a check for writability.
>
> How do you write a run-time check for writability in GENERIC though?

Well, if (writable_p) where the program appropriately sets that flag?

>  If the
> program invokes a subprogram that contains an executable store on an object
> that is a read-only memory, then execution is erroneous.  Note that the doc of
> TREE_THIS_NOTRAP suggests that it is orthogonal to readonly considerations.

Ah, I wasn't aware of that.  This makes TREE_THIS_NOTRAP possibly not
usable for tree_could_trap_p :/  One could read the docs so that it means
when you have a read with TREE_THIS_NOTRAP then you can't infer
from that that writing to it is OK though.  Rather than meaning that a write
with TREE_THIS_NOTRAP meaning that write could still trap when the store
is to readonly memory?

> > The issue is that TREE_THIS_NOTRAP is "global" and not flow-sensitive.
>
> Yes, that's the reason for all this game.

Understood.  Note I'm completely unsure as to what extent we see
TREE_THIS_NOTRAP
being used (from frontends).  I know OpenMP lowering uses it quite
extensively, IIRC
also nested function lowering.  Grepping finds a single use outside of
Ada, in go-gcc.cc

Richard.

> --
> Eric Botcazou
>
>

Reply via email to