diff options
author | Devang Patel <dpatel@apple.com> | 2008-04-08 02:24:08 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-04-08 02:24:08 +0000 |
commit | 97b746a24d298dc5b5c87f863a48ec4fade0acb4 (patch) | |
tree | 57e47781cd1e280999de2be5da9899d3316a86a1 /lib | |
parent | f35771f8135b15417114effde2ff0ac5c8da2759 (diff) | |
download | external_llvm-97b746a24d298dc5b5c87f863a48ec4fade0acb4.zip external_llvm-97b746a24d298dc5b5c87f863a48ec4fade0acb4.tar.gz external_llvm-97b746a24d298dc5b5c87f863a48ec4fade0acb4.tar.bz2 |
Fix insert point handling for multiple return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49367 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 76b565c..6cdaba5 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -117,13 +117,21 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { 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... |