[llvm] r209150 - Check the alwaysinline attribute on the call as well as on the caller.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 01:58:37 PDT 2016


(sorry for the dup, I forgot to update the list the first time....)

Wheeee commit necromancy!!!

On Mon, May 19, 2014 at 11:36 AM Peter Collingbourne <peter at pcc.me.uk>
wrote:

> Author: pcc
> Date: Mon May 19 13:25:54 2014
> New Revision: 209150
>
> URL: http://llvm.org/viewvc/llvm-project?rev=209150&view=rev
> Log:
> Check the alwaysinline attribute on the call as well as on the caller.
>
> Differential Revision: http://reviews.llvm.org/D3815


So, I reviewed this patch, and certainly the code is fine, but I wonder --
what was the motivation?

I was looking at this stuff today and I couldn't really understand why we
would want any specific semantics for call-instruction "always inline"
attributes.

I wonder if we could actually deprecate or in some way discourage frontends
from emitting them.

In recent years, Richard Smith and Evgeniy have discussed moving
always_inline toward a more rigorous model where it was invalid to place it
on a function that we could not in fact inline and require that all such
functions were in fact inlined. It turns out this in many ways better
matches what at least the Clang frontend wants in many situations. It can
emit a separate function definition to have its address taken and be used
in other ways if strictly necessary.

But if we go that route, then always_inline really needs to be a property
of the function and not the call instruction.

Thoughts? Thoughts from others?
-Chandler


>
>
> Modified:
>     llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
>     llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
>     llvm/trunk/test/Transforms/Inline/always-inline.ll
>
> Modified: llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/InlineCost.cpp?rev=209150&r1=209149&r2=209150&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/IPA/InlineCost.cpp (original)
> +++ llvm/trunk/lib/Analysis/IPA/InlineCost.cpp Mon May 19 13:25:54 2014
> @@ -1259,7 +1259,7 @@ InlineCost InlineCostAnalysis::getInline
>
>    // Calls to functions with always-inline attributes should be inlined
>    // whenever possible.
> -  if (Callee->hasFnAttribute(Attribute::AlwaysInline)) {
> +  if (CS.hasFnAttr(Attribute::AlwaysInline)) {
>      if (isInlineViable(*Callee))
>        return llvm::InlineCost::getAlways();
>      return llvm::InlineCost::getNever();
>
> Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=209150&r1=209149&r2=209150&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Mon May 19 13:25:54 2014
> @@ -95,8 +95,7 @@ InlineCost AlwaysInliner::getInlineCost(
>    // that are viable for inlining. FIXME: We shouldn't even get here for
>    // declarations.
>    if (Callee && !Callee->isDeclaration() &&
> -      Callee->getAttributes().hasAttribute(AttributeSet::FunctionIndex,
> -                                           Attribute::AlwaysInline) &&
> +      CS.hasFnAttr(Attribute::AlwaysInline) &&
>        ICA->isInlineViable(*Callee))
>      return InlineCost::getAlways();
>
>
> Modified: llvm/trunk/test/Transforms/Inline/always-inline.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/always-inline.ll?rev=209150&r1=209149&r2=209150&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/Inline/always-inline.ll (original)
> +++ llvm/trunk/test/Transforms/Inline/always-inline.ll Mon May 19 13:25:54
> 2014
> @@ -122,3 +122,14 @@ entry:
>    ret void
>  }
>
> +define i32 @inner7() {
> +  ret i32 1
> +}
> +define i32 @outer7() {
> +; CHECK-LABEL: @outer7(
> +; CHECK-NOT: call
> +; CHECK: ret
> +
> +   %r = call i32 @inner7() alwaysinline
> +   ret i32 %r
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160809/3742861f/attachment.html>


More information about the llvm-commits mailing list