Re: Changes in inline behavior on O2 optimization level for GCC 10+
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Alexey Makhmutov <a.makhmutov@postgrespro.ru>
Cc: pgsql-hackers@postgresql.org
Date: 2025-07-28T18:27:40Z
Lists: pgsql-hackers
On Sun, Jul 27, 2025 at 5:48 PM Alexey Makhmutov <a.makhmutov@postgrespro.ru> wrote: > The primary goal of this message is just to raise an awareness of this > change and its possible influence on resulting builds. I believe that clang works in the same way, and has for some time now. "clang -mllvm -debug" output shows debug instrumentation that can demonstrate that clang may inline functions that are not declared "static inline" (and decline to inline functions that are). As I understand it, to clang, the "inline" directive just lowers the threshold at which a function will be inlined. > Theoretically speaking, this change is not an issue by itself, as each > compiler is in its right to adjust its optimization logic. Certain build > pipeline could always have adjusted parameters if its maintainer is > unsatisfied with default compiler heuristics. "pg_attribute_always_inline" can be used to force the compiler to inline a function. I'd be very surprised if GCC 10 failed to honor the underlying "__attribute__((always_inline))" function attribute. -- Peter Geoghegan