Changeset View
Changeset View
Standalone View
Standalone View
lib/Target/PowerPC/PPCEarlyReturn.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | bool processBlock(MachineBasicBlock &ReturnMBB) { | ||||
(I->getOpcode() != PPC::BLR && I->getOpcode() != PPC::BLR8) || | (I->getOpcode() != PPC::BLR && I->getOpcode() != PPC::BLR8) || | ||||
I != ReturnMBB.getLastNonDebugInstr()) | I != ReturnMBB.getLastNonDebugInstr()) | ||||
return Changed; | return Changed; | ||||
SmallVector<MachineBasicBlock*, 8> PredToRemove; | SmallVector<MachineBasicBlock*, 8> PredToRemove; | ||||
for (MachineBasicBlock::pred_iterator PI = ReturnMBB.pred_begin(), | for (MachineBasicBlock::pred_iterator PI = ReturnMBB.pred_begin(), | ||||
PIE = ReturnMBB.pred_end(); PI != PIE; ++PI) { | PIE = ReturnMBB.pred_end(); PI != PIE; ++PI) { | ||||
bool OtherReference = false, BlockChanged = false; | bool OtherReference = false, BlockChanged = false; | ||||
if ((*PI)->empty()) | |||||
continue; | |||||
for (MachineBasicBlock::iterator J = (*PI)->getLastNonDebugInstr();;) { | for (MachineBasicBlock::iterator J = (*PI)->getLastNonDebugInstr();;) { | ||||
if (J == (*PI)->end()) | |||||
break; | |||||
MachineInstrBuilder MIB; | MachineInstrBuilder MIB; | ||||
if (J->getOpcode() == PPC::B) { | if (J->getOpcode() == PPC::B) { | ||||
if (J->getOperand(0).getMBB() == &ReturnMBB) { | if (J->getOperand(0).getMBB() == &ReturnMBB) { | ||||
// This is an unconditional branch to the return. Replace the | // This is an unconditional branch to the return. Replace the | ||||
// branch with a blr. | // branch with a blr. | ||||
MIB = | MIB = | ||||
BuildMI(**PI, J, J->getDebugLoc(), TII->get(I->getOpcode())); | BuildMI(**PI, J, J->getDebugLoc(), TII->get(I->getOpcode())); | ||||
MIB.copyImplicitOps(I); | MIB.copyImplicitOps(I); | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |