c - optimization of static function referenced once -


i writing embedded code msp430, using iar compiler @ highest optimization level (speed or size not change anything).

i define function static, reference once, in same file. since function has internal linkage, , used once, expected optimizer perform inline expansion. can see no reason not to.

the function short, results in 16 words of machine code. called isr. adding inline keyword makes function inline, optimizer seems need hint. having inline saves 2 push/pops stack, 1 calla , 1 reta.

am right expect inline expansion performed (even without inline keyword), or missing something?


edit: few more tests showed inline expansion dependent on size of function, , threshold quite low. seems around 15 or 16 words of machine code. above , optimizer not expand if not given keyword.

i still don't see why wouldn't (readability shouldn't concern of optimizer, should it?), understand iar can answer this.

i'm using iar arm compiler version that's few years old (v5.2); how of might apply msp430 compiler have no idea.

the iar arm compiler inlines static functions aren't explicitly marked inline me using of 'high' optimization settings, -oh (balanced), -ohs (speed), or -ohz (size) - including static functions measure of complexity (loops example).

of course, imagine there static functions aren't inlined, quick check indicates iar compiler performing optimization in general.

so, i'd expect compiler inline static function - if want depend on these optimization, think you'd need examine output (as did). of course, optimizations , how they're applied compiler dependent, iar can answer question of whether optimization 'should' occur (or defend why might decide shouldn't). might want talk iar if think aren't performing optimization appropriately. might able give pointer why it's not happening in particular case.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -