diff options
author | Roman Divacky <rdivacky@freebsd.org> | 2014-01-15 19:07:16 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@freebsd.org> | 2014-01-15 19:07:16 +0000 |
commit | dd9bfb2c1a2ad53fa3f8dfe3d8a6aa94de694297 (patch) | |
tree | a482f40b219c4607db7bc472a6d0bb3d9fd9232e /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 2e13b1c7f1005b1d9d9483f94c25b9eb92316cc9 (diff) | |
download | llvm-dd9bfb2c1a2ad53fa3f8dfe3d8a6aa94de694297.zip llvm-dd9bfb2c1a2ad53fa3f8dfe3d8a6aa94de694297.tar.gz llvm-dd9bfb2c1a2ad53fa3f8dfe3d8a6aa94de694297.tar.bz2 |
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.
llvm-svn: 199324
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 108c147..cffbca37 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/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<FunctionDecl>(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<FunctionDecl>(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<AlwaysInlineAttr>() && + !FD->hasAttr<ForceInlineAttr>()) + Fn->addFnAttr(llvm::Attribute::NoInline); + } if (getLangOpts().OpenCL) { // Add metadata for a kernel function. |