[llvm-commits] [llvm] r49367 - /llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
Devang Patel
dpatel at apple.com
Mon Apr 7 19:24:09 PDT 2008
Author: dpatel
Date: Mon Apr 7 21:24:08 2008
New Revision: 49367
URL: http://llvm.org/viewvc/llvm-project?rev=49367&view=rev
Log:
Fix insert point handling for multiple return values.
Modified:
llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
Modified: llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=49367&r1=49366&r2=49367&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Mon Apr 7 21:24:08 2008
@@ -117,13 +117,21 @@
if (NumRetVals == 0)
ReturnInst::Create(NULL, NewRetBlock);
else if (const StructType *STy = dyn_cast<StructType>(F.getReturnType())) {
- Instruction *InsertPt = NewRetBlock->getFirstNonPHI();
+ Instruction *InsertPt = NULL;
+ if (NumRetVals == 0)
+ InsertPt = NewRetBlock->getFirstNonPHI();
+ PHINode *PN = NULL;
for (unsigned i = 0; i < NumRetVals; ++i) {
- PHINode *PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
- + utostr(i), InsertPt);
+ if (InsertPt)
+ PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
+ + utostr(i), InsertPt);
+ else
+ PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
+ + utostr(i), NewRetBlock);
Phis.push_back(PN);
+ InsertPt = PN;
}
- ReturnInst::Create(&Phis[0], NumRetVals);
+ ReturnInst::Create(&Phis[0], NumRetVals, NewRetBlock);
}
else {
// If the function doesn't return void... add a PHI node to the block...
More information about the llvm-commits
mailing list