[clang] [llvm] [clang][Inliner] Add opt-in inliner hints and implementation-file functions (PR #228074)
Kuba Mracek via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 31 15:30:59 PDT 2026
================
@@ -3325,6 +3325,19 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
if (CodeGenOpts.DisableOutlining || D->hasAttr<NoOutlineAttr>())
B.addAttribute(llvm::Attribute::NoOutline);
+ // An inline function or template instantiation defined in the main source
+ // file is (ignoring unusual setups like #include-ing a .cpp file) not
+ // referenced or emitted by any other translation unit.
+ if (CodeGenOpts.ModuleLocalHints) {
+ const auto *FD = dyn_cast<FunctionDecl>(D);
+ const SourceManager &SM = getContext().getSourceManager();
+ // D->getLocation(), for a template instantiation, is the location of the
+ // template's definition, not instantiation.
+ bool InMainFile = SM.isInMainFile(D->getLocation());
+ if (FD && (FD->isInlined() || FD->isTemplateInstantiation()) && InMainFile)
----------------
kubamracek wrote:
Added a TODO comment, will consider as a follow-up
https://github.com/llvm/llvm-project/pull/228074
More information about the cfe-commits
mailing list