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