On Tue, Oct 14, 2025 at 06:02:50PM +0200, Josef Melcr wrote:
> The propagation is not considered profitable enough:
> 
> -----
> 
> Evaluating opportunities for main._omp_fn.0/1.
>  - considering value
> 1.3547000000000000152766688188421539962291717529296875e+0 for param #0
> struct .omp_data_s.0 & restrict, offset: 0 (caller_count: 1)
>      good_cloning_opportunity_p (time: 1, size: 7, freq_sum: 1) ->
> evaluation: 142.86, threshold: 500
>      good_cloning_opportunity_p (time: 1, size: 7, freq_sum: 1) ->
> evaluation: 142.86, threshold: 500
> 
> -----
> 
> You only find this out if you toggle on the detailed ipa-cp dump.  If you
> add a loop large enough before entering the parallel region, the propagation
> does take place, so something like:

Cost-wise, at least for the OpenMP/OpenACC constructs, it would be nice if
in the cost analysis it counted that while perhaps the caller happens just
once (is the problem solely with main or other functions too?), that the
callback will be called many times.
That is the usual code with OpenMP/OpenACC and certainly some other callback
attribute candidates (say qsort_r, etc.).  Though, I guess depending on how
exactly the attribute is defined, qsort_r might or might not be
representable.
Because we want to record that qsort_r's 4th argument is the callback,
5th is its argument but also that the argument isn't passed as first
argument to the callback (which is the behavior of OpenMP/OpenACC callbacks
except for GOMP_task with the cpy fn), but the third.

I think the clang attribute only allows specification of fn argument
position and its one or more arguments but those arguments are then expected
to be passed to 1st to nth arguments of the callback.

Perhaps the GNU attribute could specify both?
Arguments 2, 4 would mean fnptr is 2nd argument and its 1st argument is 4th,
so foo  (1, fn, 2, &s) calls fn (&s).
And 2, 6, 5, 4 means foo (1, fn, 2, &s, &t, &u) calls fn (&u, &t, &s).
0 is not a valid argument index, so that could be used as a separator to
where to map those arguments if not to 1-(nargs-1).
So, 2, 6, 5, 4, 0, 2, 4, 3 would mean foo (1, fn, 2, &s, &t, &u) calls
fn (?, &u, &s, &t).
I.e. 2, 4 would be equivalent to 2, 4, 0, 1 and 2, 6, 5, 4 equivalent
to 2, 6, 5, 4, 0, 1, 2, 3.

        Jakub

Reply via email to