How to make sure inline functions are really "inlined" in MCUX IDE on RT1170?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to make sure inline functions are really "inlined" in MCUX IDE on RT1170?

1,351 Views
sutter_zhou
NXP Employee
NXP Employee

When I'm using MCUX IDE for RT1170 develop, I found most inline functions are actually not inlined, but invoked as a normal function. What went wrong? I can't find anywhere to configure such behavior in the compiler settings. 

Such as "MC_PWM_UPDATE" function, it should be inlined, but it's treated as a NOT inline function:

static inline void MC_PWM_UPDATE(GMCLIB_3COOR_T_F16 *psDuty)

 

See attached project. 

 

sutter_zhou_0-1614923859401.png

 

Tags (1)
0 Kudos
4 Replies

1,335 Views
sutter_zhou
NXP Employee
NXP Employee

Hi @ErichStyger ,

This project has no optimization at all. So I think it should stick to C grammar. I can confirm that inline functions are invoked in the runtime. Do you know any macro or keywords that can make sure functions can be inlined in GCC? Thanks. 

0 Kudos

1,329 Views
sutter_zhou
NXP Employee
NXP Employee

Thanks, it helps. 

0 Kudos

1,344 Views
ErichStyger
Senior Contributor V

Hi @sutter_zhou ,

'inline' is just a hint for the compiler: if it is getting inline or not is depending on the compiler decision.

If you really want to have things inlined, you need to use a macro for the code.

Checking the map file if a symbol/function is there does not tell you if it is inlined or not: you need to check the actual calls, because if you take the address of an inlined function there will be both inlined and non-inlined versions.

And check your compiler/optimization settings: if you optimize for code size, the compiler likely will not inline as this in general increases the code size. If not already set: optimize for speed.

 

I hope this helps,

Erich

0 Kudos