diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-23 17:19:42 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-23 17:19:42 +0000 |
| commit | 2a05ea5c0eacd16922b5682042bcfe7d7bb80855 (patch) | |
| tree | 2cb87d1961dbde521f4034d775707b3927312d55 | |
| parent | 571768caa6a6146683f20afc847e8cb58b6da7e5 (diff) | |
| download | bcm5719-llvm-2a05ea5c0eacd16922b5682042bcfe7d7bb80855.tar.gz bcm5719-llvm-2a05ea5c0eacd16922b5682042bcfe7d7bb80855.zip | |
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.
llvm-svn: 199909
| -rw-r--r-- | llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 10 | ||||
| -rw-r--r-- | llvm/test/Transforms/ArgumentPromotion/tail.ll | 19 |
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 49a67211db6..ea24d526942 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -807,6 +807,16 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F, 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; } diff --git a/llvm/test/Transforms/ArgumentPromotion/tail.ll b/llvm/test/Transforms/ArgumentPromotion/tail.ll new file mode 100644 index 00000000000..e6bc557d9d0 --- /dev/null +++ b/llvm/test/Transforms/ArgumentPromotion/tail.ll @@ -0,0 +1,19 @@ +; RUN: opt %s -argpromotion -S -o - | FileCheck %s + +%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 +} |

