forked from OSchip/llvm-project
If BB is empty, insert PHI before end() instead of front().
llvm-svn: 90744
This commit is contained in:
parent
bcd035061d
commit
92c310cb79
|
@ -157,8 +157,9 @@ unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) {
|
||||||
return SingularValue;
|
return SingularValue;
|
||||||
|
|
||||||
// Otherwise, we do need a PHI: insert one now.
|
// Otherwise, we do need a PHI: insert one now.
|
||||||
|
MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front();
|
||||||
MachineInstr *InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB,
|
MachineInstr *InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB,
|
||||||
BB->front(), VRC, MRI, TII);
|
Loc, VRC, MRI, TII);
|
||||||
|
|
||||||
// Fill in all the predecessors of the PHI.
|
// Fill in all the predecessors of the PHI.
|
||||||
MachineInstrBuilder MIB(InsertedPHI);
|
MachineInstrBuilder MIB(InsertedPHI);
|
||||||
|
@ -231,7 +232,8 @@ unsigned MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){
|
||||||
// that we have a cycle. Handle this by inserting a PHI node and returning
|
// that we have a cycle. Handle this by inserting a PHI node and returning
|
||||||
// it. When we get back to the first instance of the recursion we will fill
|
// it. When we get back to the first instance of the recursion we will fill
|
||||||
// in the PHI node.
|
// in the PHI node.
|
||||||
MachineInstr *NewPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(),
|
MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front();
|
||||||
|
MachineInstr *NewPHI = InsertNewDef(TargetInstrInfo::PHI, BB, Loc,
|
||||||
VRC, MRI,TII);
|
VRC, MRI,TII);
|
||||||
unsigned NewVR = NewPHI->getOperand(0).getReg();
|
unsigned NewVR = NewPHI->getOperand(0).getReg();
|
||||||
InsertRes.first->second = NewVR;
|
InsertRes.first->second = NewVR;
|
||||||
|
@ -311,7 +313,8 @@ unsigned MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){
|
||||||
// Otherwise, we do need a PHI: insert one now if we don't already have one.
|
// Otherwise, we do need a PHI: insert one now if we don't already have one.
|
||||||
MachineInstr *InsertedPHI;
|
MachineInstr *InsertedPHI;
|
||||||
if (InsertedVal == 0) {
|
if (InsertedVal == 0) {
|
||||||
InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(),
|
MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front();
|
||||||
|
InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, Loc,
|
||||||
VRC, MRI, TII);
|
VRC, MRI, TII);
|
||||||
InsertedVal = InsertedPHI->getOperand(0).getReg();
|
InsertedVal = InsertedPHI->getOperand(0).getReg();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue