About the effect of "O0" on inlining into a function.

Iain Sandoe iain@sandoe.co.uk
Thu Jun 27 17:41:31 GMT 2024


> On 27 Jun 2024, at 14:51, Iain Sandoe <iain@sandoe.co.uk> wrote:
> 
> If I declare a function __attribute__((noipa, optimize (“-O0”))), I was kinda expecting that it would not be optimized at all .. 
> 
> however it does not seem to prevent functions called by it from being inlined into its body .. 
> 
> am I missing some additional constraint that should be added?
> 
> (I explicitly want to avoid called functions being inlined into the body, but cannot mark _those_ functions as noinline)

Additional:  If I compile the entire code “O0” then all behaves as expected.

The issue seems to be when compiing (say) O2 and a function has a local optimisation set lower (O0) .. 
perhaps this is a target problem .. 
although looking at say tree-ssa-ccp.cc I do not see any gating on the optimisation level - which I guess suggests once it’s selected in the stack .. it’s going to run…

any insights would be welcome.
Iain




More information about the Gcc mailing list