Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/ARC/ARCOptAddrMode.cpp
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
// Return true if \p MI dominates of uses of virtual register \p VReg | // Return true if \p MI dominates of uses of virtual register \p VReg | ||||
static bool dominatesAllUsesOf(const MachineInstr *MI, unsigned VReg, | static bool dominatesAllUsesOf(const MachineInstr *MI, unsigned VReg, | ||||
MachineDominatorTree *MDT, | MachineDominatorTree *MDT, | ||||
MachineRegisterInfo *MRI) { | MachineRegisterInfo *MRI) { | ||||
assert(Register::isVirtualRegister(VReg) && "Expected virtual register!"); | assert(Register::isVirtualRegister(VReg) && "Expected virtual register!"); | ||||
for (auto it = MRI->use_nodbg_begin(VReg), end = MRI->use_nodbg_end(); | for (const MachineOperand &Use : MRI->use_nodbg_operands(VReg)) { | ||||
it != end; ++it) { | const MachineInstr *User = Use.getParent(); | ||||
MachineInstr *User = it->getParent(); | |||||
if (User->isPHI()) { | if (User->isPHI()) { | ||||
unsigned BBOperandIdx = User->getOperandNo(&*it) + 1; | unsigned BBOperandIdx = Use.getOperandNo() + 1; | ||||
MachineBasicBlock *MBB = User->getOperand(BBOperandIdx).getMBB(); | MachineBasicBlock *MBB = User->getOperand(BBOperandIdx).getMBB(); | ||||
if (MBB->empty()) { | if (MBB->empty()) { | ||||
const MachineBasicBlock *InstBB = MI->getParent(); | const MachineBasicBlock *InstBB = MI->getParent(); | ||||
assert(InstBB != MBB && "Instruction found in empty MBB"); | assert(InstBB != MBB && "Instruction found in empty MBB"); | ||||
if (!MDT->dominates(InstBB, MBB)) | if (!MDT->dominates(InstBB, MBB)) | ||||
return false; | return false; | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |