- // If this is the first time we see a subregister def/use. Initialize
- // subranges by creating a copy of the main range.
- if (!LI.hasSubRanges()) {
- unsigned ClassMask = MRI->getMaxLaneMaskForVReg(Reg);
- LI.createSubRangeFrom(*Alloc, ClassMask, LI);
- LiveOuts.insert(LiveOuts.begin(), LiveOutData());
- LiveOuts.front().reset(MF->getNumBlockIDs());
- ++NumSubRanges;
- }
- unsigned SubRangeIdx = 0;
- for (LiveInterval::subrange_iterator S = LI.subrange_begin(),
- SE = LI.subrange_end(); S != SE; ++S, ++SubRangeIdx) {
- // A Mask for subregs common to the existing subrange and current def.
- unsigned Common = S->LaneMask & Mask;
- if (Common == 0)
- continue;
- // A Mask for subregs covered by the subrange but not the current def.
- unsigned LRest = S->LaneMask & ~Mask;
- LiveInterval::SubRange *CommonRange;
- unsigned CommonRangeIdx;
- if (LRest != 0) {
- // Split current subrange into Common and LRest ranges.
- S->LaneMask = LRest;
- CommonRange = LI.createSubRangeFrom(*Alloc, Common, *S);
- CommonRangeIdx = 0;
- LiveOuts.insert(LiveOuts.begin(), LiveOutData());
- LiveOuts.front().reset(MF->getNumBlockIDs());
- ++NumSubRanges;
- ++SubRangeIdx;
- } else {
- // The subrange and current def lanemasks match completely.
- assert(Common == S->LaneMask);
- CommonRange = &*S;
- CommonRangeIdx = SubRangeIdx;
- }
- extend(*CommonRange, Idx, Reg, LiveOuts[CommonRangeIdx]);
- Mask &= ~Common;
+ // Determine the actual place of the use.
+ const MachineInstr *MI = MO.getParent();
+ unsigned OpNo = (&MO - &MI->getOperand(0));
+ SlotIndex UseIdx;
+ if (MI->isPHI()) {
+ assert(!MO.isDef() && "Cannot handle PHI def of partial register.");
+ // The actual place where a phi operand is used is the end of the pred
+ // MBB. PHI operands are paired: (Reg, PredMBB).
+ UseIdx = Indexes->getMBBEndIdx(MI->getOperand(OpNo+1).getMBB());
+ } else {
+ // Check for early-clobber redefs.
+ bool isEarlyClobber = false;
+ unsigned DefIdx;
+ if (MO.isDef())
+ isEarlyClobber = MO.isEarlyClobber();
+ else if (MI->isRegTiedToDefOperand(OpNo, &DefIdx)) {
+ // FIXME: This would be a lot easier if tied early-clobber uses also
+ // had an early-clobber flag.
+ isEarlyClobber = MI->getOperand(DefIdx).isEarlyClobber();