AnsweredAssumed Answered

Low-Level (LL) Driver library functions are not inlined by default with GCC

Question asked by Code Wrangler on Sep 20, 2017
Latest reply on Sep 20, 2017 by waclawek.jan

To people switching their code over to the Low-Level (LL) Driver libraries from HAL for improved performance:

 

Surprise!!!

 

You may not actually be getting much better performance.

 

So it turns out that 'inline' doesn't really mean 'inline' to GCC. Rather, it is more like a hint that GCC is free to ignore. And does ignore in the default setting without optimizations (-O0).

 

Basically, if you want the LL driver library functions to be inlined (and thus actually significantly improve the performance over HAL), you need to specify an optimization level (i.e. -O1, -O2, -O3, -Os, -Og). I recommend -Og for debug builds as it doesn't enable optimizations that break the ability to debug. It appears that any optimization level past -O0 will inline functions.

 

I only noticed this because I was switching all my direct register access code over to LL and looked at the disassembly window when I hit a breakpoint.

Outcomes