[clang] [Clang][Inliner] Enable module-local optimizer hints by default (PR #238529)

Kuba Mracek via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 13:56:23 PST 2026


kubamracek wrote:

> should we restrict emitting the flag only to linkonce_odr linkage?

Right now, Clang emits the `likely_module_local` hint on .cpp-file code that's either templated or has the inline specifier, regardless of the linkage. That covers linkonce_odr definitions, but not exclusively: Anynomous namespaces are internal linkage, explicit instantiations are weak_odr.

Right now, LLVM only does anything with the hint on linkonce_odr functions.

The minimal implementation would be to restrict the Clang logic to only emit the hint for linkonce_odr. But I'm currently thinking that it'd be best to treat the hint as more general than that, because there's interesting future ideas that could allow optimizations beyond linkonce_odr (https://discourse.llvm.org/t/rfc-optimizing-linkonce-odr-functions-frontend-hints-inlining-and-internal-cloning/92423/15). There's no harm in the `likely_module_local` attribute getting emitted on unused linkages, and thus I would propose we keep emitting it beyond linkonce_odr.

(In fact, I am currently exploring perf opportunities about the same "is this from an implementation file instead of a header file" hint but for non-templated code, which means even expanding the Clang logic to even more linkage types.)

https://github.com/llvm/llvm-project/pull/238529


More information about the cfe-commits mailing list