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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

2,150 次查看
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

 

标记 (1)
0 项奖励
回复
4 回复数

2,134 次查看
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 项奖励
回复

2,132 次查看
converse
Senior Contributor V

2,128 次查看
sutter_zhou
NXP Employee
NXP Employee

Thanks, it helps. 

0 项奖励
回复

2,143 次查看
ErichStyger
Specialist I

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 项奖励
回复