From 93de7bb38c1c57f8b8bafcb697bb5030793a9d6c Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Wed, 15 Jan 2014 19:07:16 +0000 Subject: Make -fno-inline attach NoInline attribute to all functions that are not marked as AlwaysInline or ForceInline. This moves us to what gcc does with -fno-inline. The attribute approach was discussed to be better than switching to InlineAlways inliner in presence of LTO. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199324 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 108c147781..cffbca37bd 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -509,15 +509,20 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, } // Pass inline keyword to optimizer if it appears explicitly on any - // declaration. - if (!CGM.getCodeGenOpts().NoInline) - if (const FunctionDecl *FD = dyn_cast_or_null(D)) + // declaration. Also, in the case of -fno-inline attach NoInline + // attribute to all function that are not marked AlwaysInline or ForceInline. + if (const FunctionDecl *FD = dyn_cast_or_null(D)) { + if (!CGM.getCodeGenOpts().NoInline) { for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(), RE = FD->redecls_end(); RI != RE; ++RI) if (RI->isInlineSpecified()) { Fn->addFnAttr(llvm::Attribute::InlineHint); break; } + } else if (!FD->hasAttr() && + !FD->hasAttr()) + Fn->addFnAttr(llvm::Attribute::NoInline); + } if (getLangOpts().OpenCL) { // Add metadata for a kernel function. -- cgit v1.2.3