diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-06-22 16:56:16 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-06-22 16:56:16 +0000 |
commit | 44d061a4714769b33e17c6099a35a61e3c62b726 (patch) | |
tree | 7773dc6d0c287f39e9afddf854ff5be755c83fb8 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | eeec4c83648a9a296724c801e1a3fa8686270d4e (diff) | |
download | bcm5719-llvm-44d061a4714769b33e17c6099a35a61e3c62b726.tar.gz bcm5719-llvm-44d061a4714769b33e17c6099a35a61e3c62b726.zip |
Add support for /Ob1 and -finline-hint-functions flags
Add support for /Ob1 (and equivalent -finline-hint-functions), which enable
inlining only for functions marked inline, either explicitly (via inline
keyword, for example), or implicitly (function definition in class body,
for example).
This works by enabling inlining pass, and adding noinline attribute to
every function not marked inline.
Patch by Rudy Pons <rudy.pons@ilod.org>!
Differential Revision: http://reviews.llvm.org/D20647
llvm-svn: 273440
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 99f40e3ade6..1d46eea45fd 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -686,14 +686,20 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, // Pass inline keyword to optimizer if it appears explicitly on any // declaration. Also, in the case of -fno-inline attach NoInline - // attribute to all function that are not marked AlwaysInline. + // attribute to all functions that are not marked AlwaysInline, or + // to all functions that are not marked inline or implicitly inline + // in the case of -finline-hint-functions. if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) { - if (!CGM.getCodeGenOpts().NoInline) { + const CodeGenOptions& CodeGenOpts = CGM.getCodeGenOpts(); + if (!CodeGenOpts.NoInline) { for (auto RI : FD->redecls()) if (RI->isInlineSpecified()) { Fn->addFnAttr(llvm::Attribute::InlineHint); break; } + if (CodeGenOpts.getInlining() == CodeGenOptions::OnlyHintInlining && + !FD->isInlined() && !Fn->hasFnAttribute(llvm::Attribute::InlineHint)) + Fn->addFnAttr(llvm::Attribute::NoInline); } else if (!FD->hasAttr<AlwaysInlineAttr>()) Fn->addFnAttr(llvm::Attribute::NoInline); if (CGM.getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>()) |