r199324 - Make -fno-inline attach NoInline attribute to all functions that are not
Roman Divacky
rdivacky at freebsd.org
Wed Jan 15 11:07:17 PST 2014
Author: rdivacky
Date: Wed Jan 15 13:07:16 2014
New Revision: 199324
URL: http://llvm.org/viewvc/llvm-project?rev=199324&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/noinline.c
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=199324&r1=199323&r2=199324&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jan 15 13:07:16 2014
@@ -509,15 +509,20 @@ void CodeGenFunction::StartFunction(Glob
}
// 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.
Modified: cfe/trunk/test/CodeGen/noinline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/noinline.c?rev=199324&r1=199323&r2=199324&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/noinline.c (original)
+++ cfe/trunk/test/CodeGen/noinline.c Wed Jan 15 13:07:16 2014
@@ -5,10 +5,17 @@
inline int dont_inline_me(int a, int b) { return(a+b); }
+inline __attribute__ ((__always_inline__)) int inline_me(int a, int b) { return(a*b); }
+
volatile int *pa = (int*) 0x1000;
void foo() {
// NOINLINE: @foo
// NOINLINE: dont_inline_me
// NOINLINE-NOT: inlinehint
pa[0] = dont_inline_me(pa[1],pa[2]);
+// NOINLINE-NOT: inline_me
+ pa[3] = inline_me(pa[4],pa[5]);
}
+
+// NOINLINE: Function Attrs: noinline
+// NOINLINE: @dont_inline_me
More information about the cfe-commits
mailing list