> Hi,
> 
> On 10/9/25 23:06, Jakub Jelinek wrote:
> > On Thu, Oct 09, 2025 at 10:25:45PM +0200, Josef Melcr wrote:
> > > On 10/9/25 12:58, Tobias Burnus wrote:
> > > > Still, I think enabling it always with -O2 - or at least when
> > > > 'static' and only called once makes sense.
> > > Enabling it by default for static functions only called once is a good
> > > start.  It makes a lot of sense and it will also allow me to gauge the
> > > complexity of solving the rest.
> > Doesn't have to be necessarily called just once, but it really needs
> > to be static and not called directly and only called in the case with
> > explicit or implicit GNU callback attribute (because those attributes
> > guarantee that the callee to which the callback is passed doesn't leak it
> > anywhere where something else could call those).
> You are right, thank you for pointing that out.  We could probably implement
> it incrementally, start with simple cases like called once and then expand
> it further.

Note that current ipa-cp implementation at -O2 will happily propagate in
cases which needs no cloning controlled by -fipa-cp-clone.  So making it
to also propagate into openMP kernels provided that doing so needs to
code duplication is consistent with current implementation.

For normal cloning we use node->local flag that tests that all calls to
the function are under our control (function is only called directly,
not exported and has no address taken).

We need to compute equivalent of this flag for kernels which is not too
hard.  We only want to check that the kernel is not called directly, not
exported and all calls are those having callback attribute on them.

Honza
> > BTW, for .ASSUME ifn which really would be nice to get handled as well,
> > it also due to inlining can have multiple callers, but the function in
> > that case is magic, not actually emitted into assembly.  And while e.g.
> > cp into the function might help, the most important would be IPA-SRA.
> > If it agrees on all callers (or clones the magic function), in that case
> > it even doesn't have to keep a single pointer data pointing to some
> > structure, it can change the number of arguments to the function, and
> > ideally split all the ones passing structures to the actually used scalar
> > elements.
> ASSUME is on my mind since it was first mentioned when I submitted v1 of
> this patch.  With the special casing mechanism in place, it would definitely
> be possible, but the thing I kinda struggle with is priority.  I do have
> some top priorities, like implementing the summary to save space in the
> cgraph_edge class, but then there are features like the GOMP_task copy
> function support, omp target or IFN_ASSUME support and I am not sure which
> of these is the most important.  Do you have any thoughts on that? :)
> >     Jakub
> 
> Best regards,
> 
> Josef
> 

Reply via email to