mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 22:32:47 +00:00
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
This commit is contained in:
parent
f2247cfb38
commit
34437f35e9
@ -117,13 +117,21 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
|
|||||||
if (NumRetVals == 0)
|
if (NumRetVals == 0)
|
||||||
ReturnInst::Create(NULL, NewRetBlock);
|
ReturnInst::Create(NULL, NewRetBlock);
|
||||||
else if (const StructType *STy = dyn_cast<StructType>(F.getReturnType())) {
|
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) {
|
for (unsigned i = 0; i < NumRetVals; ++i) {
|
||||||
PHINode *PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal."
|
if (InsertPt)
|
||||||
+ utostr(i), 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);
|
Phis.push_back(PN);
|
||||||
|
InsertPt = PN;
|
||||||
}
|
}
|
||||||
ReturnInst::Create(&Phis[0], NumRetVals);
|
ReturnInst::Create(&Phis[0], NumRetVals, NewRetBlock);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If the function doesn't return void... add a PHI node to the block...
|
// If the function doesn't return void... add a PHI node to the block...
|
||||||
|
Loading…
Reference in New Issue
Block a user