[PATCH]: -fno-inline doesnt prevent inlining
Alp Toker
alp at nuanti.com
Tue Jan 14 12:14:46 PST 2014
On 14/01/2014 19:58, Roman Divacky wrote:
> Hi,
>
> Currently -fno-inline doesnt do much, it just prevents adding InlineHint
> attributes. This means that we differ from gcc which prevents all
> functions (except always_inline) from inlining. This simple patch
> implements that behaviour, is that ok?
>
> Index: lib/CodeGen/CodeGenFunction.cpp
> ===================================================================
> --- lib/CodeGen/CodeGenFunction.cpp (revision 199224)
> +++ lib/CodeGen/CodeGenFunction.cpp (working copy)
> @@ -510,7 +510,7 @@
>
> // Pass inline keyword to optimizer if it appears explicitly on any
> // declaration.
> - if (!CGM.getCodeGenOpts().NoInline)
> + if (!CGM.getCodeGenOpts().NoInline) {
> if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
> for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(),
> RE = FD->redecls_end(); RI != RE; ++RI)
> @@ -518,6 +518,10 @@
> Fn->addFnAttr(llvm::Attribute::InlineHint);
> break;
> }
> + } else if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Hi Roman,
Point of style: How about reusing the existing dyn_cast_or_null case and
just moving the CGM.getCodeGenOpts().NoInline check inside?
As for the functionality change, it seems to make sense but leaving it
to CodeGen regulars to give the nod.
Alp.
> + if (!FD->hasAttr<AlwaysInlineAttr>() &&
> + !FD->hasAttr<ForceInlineAttr>())
> + Fn->addFnAttr(llvm::Attribute::NoInline);
>
> if (getLangOpts().OpenCL) {
> // Add metadata for a kernel function.
> Index: test/CodeGen/noinline.c
> ===================================================================
> --- test/CodeGen/noinline.c (revision 199224)
> +++ test/CodeGen/noinline.c (working copy)
> @@ -7,6 +7,7 @@
>
> volatile int *pa = (int*) 0x1000;
> void foo() {
> +// NOINLINE: Function Attrs: noinline
> // NOINLINE: @foo
> // NOINLINE: dont_inline_me
> // NOINLINE-NOT: inlinehint
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
--
http://www.nuanti.com
the browser experts
More information about the cfe-commits
mailing list