aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-09-08 19:53:15 +0000
committerOwen Anderson <resistor@mac.com>2009-09-08 19:53:15 +0000
commita0ecbe782177d3ec7c98700434d2d92fb0c0e600 (patch)
tree3fd2217c4c89ced5ceb566ba33fc4e8b2b7570a0
parentc22675b5428d579d4eca15ee8a0ff701942738c4 (diff)
downloadexternal_llvm-a0ecbe782177d3ec7c98700434d2d92fb0c0e600.zip
external_llvm-a0ecbe782177d3ec7c98700434d2d92fb0c0e600.tar.gz
external_llvm-a0ecbe782177d3ec7c98700434d2d92fb0c0e600.tar.bz2
Fix PR4909, patch by Jakub Staszak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81250 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/PartialInlining.cpp3
-rw-r--r--test/Transforms/Inline/PR4909.ll15
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/PartialInlining.cpp b/lib/Transforms/IPO/PartialInlining.cpp
index 73ec9c1..8f858d3 100644
--- a/lib/Transforms/IPO/PartialInlining.cpp
+++ b/lib/Transforms/IPO/PartialInlining.cpp
@@ -48,7 +48,8 @@ ModulePass* llvm::createPartialInliningPass() { return new PartialInliner(); }
Function* PartialInliner::unswitchFunction(Function* F) {
// First, verify that this function is an unswitching candidate...
BasicBlock* entryBlock = F->begin();
- if (!isa<BranchInst>(entryBlock->getTerminator()))
+ BranchInst *BR = dyn_cast<BranchInst>(entryBlock->getTerminator());
+ if (!BR || BR->isUnconditional())
return 0;
BasicBlock* returnBlock = 0;
diff --git a/test/Transforms/Inline/PR4909.ll b/test/Transforms/Inline/PR4909.ll
new file mode 100644
index 0000000..48b2526
--- /dev/null
+++ b/test/Transforms/Inline/PR4909.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -partial-inliner -disable-output
+
+define i32 @f() {
+entry:
+ br label %return
+
+return: ; preds = %entry
+ ret i32 undef
+}
+
+define i32 @g() {
+entry:
+ %0 = call i32 @f()
+ ret i32 %0
+}