From ca704957972df96a86f4ef90ce992bce5a9b60e9 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 15 Mar 2010 19:05:46 +0000 Subject: In "empty" bb, the return instruction may not be first instruction, if dbg value intrinsics are present in this bb. Use terminator to find return instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98565 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/SimplifyCFGPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp index 952d1a8..738c5e8 100644 --- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -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(RetBlock->begin()); if (RetBlockPHI == 0) { - Value *InVal = cast(RetBlock->begin())->getOperand(0); + Value *InVal = cast(RetBlock->getTerminator())->getOperand(0); RetBlockPHI = PHINode::Create(Ret->getOperand(0)->getType(), "merge", &RetBlock->front()); -- cgit v1.1