Make GCC smooth and optimize one function?

I am trying to make GCC inline all calls into one specific function and optimize it regardless of global optimization parameters. The attribute flattenseems to do what I want, but only when the entire source file is compiled with the same -O option. When specifying as __attribute__((flatten, optimize("O2"))), GCC apparently ignores the flatten attribute if the rest of the source file is compiled with any other setting than -O2.

This particular function is an interrupt routine, and I need to make sure that the whole function is contained in one contiguous piece of memory. The only function calls are: __builtin_ia32_rdtsc()(which consists of only rdtscand ret) and two operations std::atomic.

So, as the name says, is there a way to make these calls be built-in and optimized?

+4
source share

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


All Articles