+/// hasRegisterUseBelow - Return true if the specified register is used after
+/// the current instruction and before it's next definition.
+bool LiveVariables::hasRegisterUseBelow(unsigned Reg,
+ MachineBasicBlock::iterator I,
+ MachineBasicBlock *MBB) {
+ if (I == MBB->end())
+ return false;
+ ++I;
+ // FIXME: This is slow. We probably need a smarter solution. Possibilities:
+ // 1. Scan all instructions once and build def / use information of physical
+ // registers. We also need a fast way to compare relative ordering of
+ // instructions.
+ // 2. Cache information so this function only has to scan instructions that
+ // read / def physical instructions.
+ for (MachineBasicBlock::iterator E = MBB->end(); I != E; ++I) {
+ MachineInstr *MI = I;
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = MI->getOperand(i);
+ if (!MO.isRegister() || MO.getReg() != Reg)
+ continue;
+ if (MO.isDef())
+ return false;
+ return true;
+ }
+ }
+ return false;
+}
+