Propagation of attributes from functions to CallSites

Hi all,

I investigated the PostOrderFunctionAttrsPass and the removal of the convergent attribute in particular, and there is something that seems odd to me.

Why the removal of the attribute from the CallSite happen in a later pass (InstCombine)
and doesn’t occur in PostOrderFunctionAttrsPass, where the convergent attribute is actually being removed from the function.

Small example :

The function ‘non_convergent_function’ marked with convergent attribute but isn’t actually a convergent function - so PostOrderFunctionAttrsPass can remove the convergent attribute and will do it but it won’t remove the attribute from the CallSite.

It seems that we lose opportunities to optimize code this way , for example the convergent attribute can block some optimizations(SimplifyCFG, LoopUnswitch, LoopUnroll and more).

If we run PostOrderFunctionAttrsPass and then InstCombine then the attribute is removed from the CallSite as well but we lost the opportunity to optimize code until we will remove the convergent attribute from the CallSite in the next run of PostOrderFunctionAttrsPass .

So, I guess my question is what the logic behind this ? why not remove the CallSite attribute right after the removal of the function attribute ?


FWIW, my plan is to run the Lightweight Attributor instead of the PostOrderFunctionAttrPass soon. I’m working on getting the compile time down.
Attributor’s AANoConvergent does what you want: Compiler Explorer

I should be able to post new compile times soon.

(Tag @fhahn, @nikic)

1 Like