cancel
Showing results for 
Search instead for 
Did you mean: 

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

Code Wrangler
Associate III
Posted on September 20, 2017 at 16:57

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.

1 REPLY 1
Posted on September 20, 2017 at 17:18