Static Function Optimization

I am writing inline code for the MSP430 using the IAR compiler at the highest level of optimization (speed or size do not change anything).

I define the function as static and then refer only once in the same file. Since the function has an internal connection and is used exactly once, I expected the optimizer to perform the built-in extension. I see no reason for this.

The function is short, this leads to 16 words of machine code. It is called from the ISR. Adding the inline keyword makes the function inline, but the optimizer seems to need some help. Having an inline string, it saves two push/ popper stack, one callaand one reta.

Can I expect the built-in extension to complete (even without a keyword inline), or am I missing something?


Edit: A few more tests showed that the built-in extension depended on the size of the function and that the threshold was pretty low. This seems to be about 15 or 16 words of machine code. Above this, the optimizer does not expand unless a keyword is specified.

I still don't understand why this is not (readability should not be an optimizer problem, right?), But I understand that the IAR can only answer that.

+3
source share
3 answers

I use the ARM IAR compiler version, which is several years old (v5.2); As far as this can be applied to the MSP430 compiler, I have no idea.

IAR ARM , inline , "" , -Oh (), -Ohs () -Ohz ( ), (, ).

, , , , , IAR .

, , , , , ( ). , , , IAR , "" ( , , ). , IAR, , . , .

+2

( inline), . ( , ).

, , , , .

_force_inline , , ( inline ).

, . , , , .

[edit] , #pragma inline=forced . , - .

+2

IAR IAR :

, . , , -, "multifile ", C , . , , IDE .

...

, --mfc. , , , ++ .

0

Source: https://habr.com/ru/post/1792988/


All Articles