[llvm] r199909 - Remove tail marker when changing an argument to an alloca.

Nick Lewycky nicholas at mxc.ca
Thu Jan 23 11:43:09 PST 2014


Rafael Espindola wrote:
> Author: rafael
> Date: Thu Jan 23 11:19:42 2014
> New Revision: 199909
>
> URL: http://llvm.org/viewvc/llvm-project?rev=199909&view=rev
> Log:
> Remove tail marker when changing an argument to an alloca.
>
> Argument promotion can replace an argument of a call with an alloca. This
> requires clearing the tail marker as it is very likely that the callee is now
> using an alloca in the caller.
>
> This fixes pr14710.
>
> Added:
>      llvm/trunk/test/Transforms/ArgumentPromotion/tail.ll
> Modified:
>      llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
>
> Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=199909&r1=199908&r2=199909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Jan 23 11:19:42 2014
> @@ -807,6 +807,16 @@ CallGraphNode *ArgPromotion::DoPromotion
>         I->replaceAllUsesWith(TheAlloca);
>         TheAlloca->takeName(I);
>         AA.replaceWithNewValue(I, TheAlloca);
> +
> +      // If the alloca is used in a call, we must clear the tail flag since
> +      // the callee now uses an alloca from the caller.
> +      for (Value::use_iterator UI = TheAlloca->use_begin(),
> +             E = TheAlloca->use_end(); UI != E; ++UI) {
> +        CallInst *Call = dyn_cast<CallInst>(*UI);
> +        if (!Call)
> +          continue;
> +        Call->setTailCall(false);
> +      }
>         continue;
>       }
>
>
> Added: llvm/trunk/test/Transforms/ArgumentPromotion/tail.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/tail.ll?rev=199909&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/ArgumentPromotion/tail.ll (added)
> +++ llvm/trunk/test/Transforms/ArgumentPromotion/tail.ll Thu Jan 23 11:19:42 2014
> @@ -0,0 +1,19 @@
> +; RUN: opt %s -argpromotion -S -o - | FileCheck %s

Add "; PR14710"?

> +
> +%pair = type { i32, i32 }
> +
> +declare i8* @foo(%pair*)
> +
> +define internal void @bar(%pair* byval %Data) {
> +; CHECK: define internal void @bar(i32 %Data.0, i32 %Data.1)
> +; CHECK: %Data = alloca %pair
> +; CHECK-NOT: tail
> +; CHECK: call i8* @foo(%pair* %Data)
> +  tail call i8* @foo(%pair* %Data)
> +  ret void
> +}
> +
> +define void @zed(%pair* byval %Data) {
> +  call void @bar(%pair* byval %Data)
> +  ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list