Lines Matching +full:keep +full:- +full:a +full:- +full:live

1 //===-- LiveRangeEdit.cpp - Basic tools for editing a register live range -===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // The LiveRangeEdit class represents changes done to a virtual register when it
11 //===----------------------------------------------------------------------===//
29 STATISTIC(NumFracRanges, "Number of live ranges fractured by DCE");
38 VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg)); in createEmptyIntervalFrom()
41 if (Parent && !Parent->isSpillable()) in createEmptyIntervalFrom()
45 // the main range here---it will be constructed later after the subranges in createEmptyIntervalFrom()
58 VRM->setIsSplitFromReg(VReg, VRM->getOriginal(OldReg)); in createFrom()
66 if (Parent && !Parent->isSpillable()) in createFrom()
83 if (VNI->isUnused()) in scanRemattable()
85 Register Original = VRM->getOriginal(getReg()); in scanRemattable()
87 VNInfo *OrigVNI = OrigLI.getVNInfoAt(VNI->def); in scanRemattable()
90 MachineInstr *DefMI = LIS.getInstructionFromIndex(OrigVNI->def); in scanRemattable()
104 /// allUsesAvailableAt - Return true if all registers used by OrigMI at
111 for (const MachineOperand &MO : OrigMI->operands()) { in allUsesAvailableAt()
115 // We can't remat physreg uses, unless it is a constant or target wants in allUsesAvailableAt()
137 // Check that subrange is live at UseIdx. in allUsesAvailableAt()
141 LaneBitmask LM = SubReg ? TRI->getSubRegIndexLaneMask(SubReg) in allUsesAvailableAt()
193 (*--MI).clearRegisterDeads(DestReg); in rematerializeAt()
199 return LIS.getSlotIndexes()->insertMachineInstrInMaps(*MI, Late).getRegSlot(); in rematerializeAt()
203 if (TheDelegate && TheDelegate->LRE_CanEraseVirtReg(Reg)) in eraseVirtReg()
211 // Check that there is a single def and a single use. in foldAsLoad()
212 for (MachineOperand &MO : MRI.reg_nodbg_operands(LI->reg())) { in foldAsLoad()
217 if (!MI->canFoldAsLoad()) in foldAsLoad()
232 // Since we're moving the DefMI load, make sure we're not extending any live in foldAsLoad()
241 if (!DefMI->isSafeToMove(nullptr, SawStore)) in foldAsLoad()
248 if (UseMI->readsWritesVirtualRegister(LI->reg(), &Ops).second) in foldAsLoad()
257 if (UseMI->shouldUpdateCallSiteInfo()) in foldAsLoad()
258 UseMI->getMF()->moveCallSiteInfo(UseMI, FoldMI); in foldAsLoad()
259 UseMI->eraseFromParent(); in foldAsLoad()
260 DefMI->addRegisterDead(LI->reg(), nullptr); in foldAsLoad()
282 /// Find all live intervals that need to shrink, then remove the instruction.
284 assert(MI->allDefsAreDead() && "Def isn't really dead"); in eliminateDeadDef()
287 // Never delete a bundled instruction. in eliminateDeadDef()
288 if (MI->isBundled()) { in eliminateDeadDef()
296 if (MI->isInlineAsm()) { in eliminateDeadDef()
303 if (!MI->isSafeToMove(nullptr, SawStore)) { in eliminateDeadDef()
319 if (VRM && MI->getOperand(0).isReg() && MI->getOperand(0).isDef() && in eliminateDeadDef()
320 MI->getDesc().getNumDefs() == 1) { in eliminateDeadDef()
321 Dest = MI->getOperand(0).getReg(); in eliminateDeadDef()
322 DestSubReg = MI->getOperand(0).getSubReg(); in eliminateDeadDef()
323 Register Original = VRM->getOriginal(Dest); in eliminateDeadDef()
326 // The original live-range may have been shrunk to in eliminateDeadDef()
327 // an empty live-range. It happens when it is dead, but in eliminateDeadDef()
328 // we still keep it around to be able to rematerialize in eliminateDeadDef()
331 isOrigDef = SlotIndex::isSameInstr(OrigVNI->def, Idx); in eliminateDeadDef()
336 // Check for live intervals that may shrink in eliminateDeadDef()
337 for (const MachineOperand &MO : MI->operands()) { in eliminateDeadDef()
354 // Always shrink COPY uses that probably come from live range splitting. in eliminateDeadDef()
355 if ((MI->readsVirtualRegister(Reg) && in eliminateDeadDef()
365 TheDelegate->LRE_WillShrinkVirtReg(LI.reg()); in eliminateDeadDef()
372 // Currently, we don't support DCE of physreg live ranges. If MI reads in eliminateDeadDef()
374 // a KILL instead. This way, the physreg live ranges don't end up in eliminateDeadDef()
380 MI->setDesc(TII.get(TargetOpcode::KILL)); in eliminateDeadDef()
382 for (unsigned i = MI->getNumOperands(); i; --i) { in eliminateDeadDef()
383 const MachineOperand &MO = MI->getOperand(i-1); in eliminateDeadDef()
386 MI->removeOperand(i-1); in eliminateDeadDef()
391 // don't delete the inst. Replace the dest with a new reg, and keep in eliminateDeadDef()
397 // and later result in an invalid live segment end. in eliminateDeadDef()
408 Alloc, TRI->getSubRegIndexLaneMask(DestSubReg)); in eliminateDeadDef()
409 SR->addSegment(LiveInterval::Segment(Idx, Idx.getDeadSlot(), in eliminateDeadDef()
410 SR->getNextValue(Idx, Alloc))); in eliminateDeadDef()
414 DeadRemats->insert(MI); in eliminateDeadDef()
416 MI->substituteRegister(Dest, NewLI.reg(), 0, TRI); in eliminateDeadDef()
417 assert(MI->registerDefIsDead(NewLI.reg(), &TRI)); in eliminateDeadDef()
420 TheDelegate->LRE_WillEraseInstruction(MI); in eliminateDeadDef()
422 MI->eraseFromParent(); in eliminateDeadDef()
428 // uses around. Keep the empty live range in that case. in eliminateDeadDef()
449 // Shrink just one live interval. Then delete new dead defs. in eliminateDeadDefs()
453 Register VReg = LI->reg(); in eliminateDeadDefs()
455 TheDelegate->LRE_WillShrinkVirtReg(VReg); in eliminateDeadDefs()
459 // Don't create new intervals for a register being spilled. in eliminateDeadDefs()
467 LI->RenumberValues(); in eliminateDeadDefs()
473 Register Original = VRM ? VRM->getOriginal(VReg) : Register(); in eliminateDeadDefs()
479 VRM->setIsSplitFromReg(SplitLI->reg(), Original); in eliminateDeadDefs()
481 TheDelegate->LRE_DidCloneVirtReg(SplitLI->reg(), VReg); in eliminateDeadDefs()
486 // Keep track of new virtual registers created via
491 VRM->grow(); in MRI_NoteNewVirtualRegister()
504 << TRI->getRegClassName(MRI.getRegClass(LI.reg())) << '\n'; in calculateRegClassAndHint()