Fix PR4909, patch by Jakub Staszak.
authorOwen Anderson <resistor@mac.com>
Tue, 8 Sep 2009 19:53:15 +0000 (19:53 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 8 Sep 2009 19:53:15 +0000 (19:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81250 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/PartialInlining.cpp
test/Transforms/Inline/PR4909.ll [new file with mode: 0644]

index 73ec9c1076375fbf2d753d131aa084e4eb910c4e..8f858d35ea3f52127e60e86c2fb6f716a068ad3f 100644 (file)
@@ -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();
 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;
     return 0;
   
   BasicBlock* returnBlock = 0;
diff --git a/test/Transforms/Inline/PR4909.ll b/test/Transforms/Inline/PR4909.ll
new file mode 100644 (file)
index 0000000..48b2526
--- /dev/null
@@ -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
+}