In "empty" bb, the return instruction may not be first instruction, if dbg value...
authorDevang Patel <dpatel@apple.com>
Mon, 15 Mar 2010 19:05:46 +0000 (19:05 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 15 Mar 2010 19:05:46 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SimplifyCFGPass.cpp

index 952d1a8ffb84ef18be2f08c353440f7af397af71..738c5e8d13d1dd41ab9de95209855b15a6d8d89c 100644 (file)
@@ -244,7 +244,7 @@ static bool MergeEmptyReturnBlocks(Function &F) {
     // If the canonical return block has no PHI node, create one now.
     PHINode *RetBlockPHI = dyn_cast<PHINode>(RetBlock->begin());
     if (RetBlockPHI == 0) {
-      Value *InVal = cast<ReturnInst>(RetBlock->begin())->getOperand(0);
+      Value *InVal = cast<ReturnInst>(RetBlock->getTerminator())->getOperand(0);
       RetBlockPHI = PHINode::Create(Ret->getOperand(0)->getType(), "merge",
                                     &RetBlock->front());