Lines Matching +full:non +full:- +full:live
1 //===- InstrRefBasedImpl.cpp - Tracking Debug Value MIs -------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
17 /// map of instruction-to-value is then translated into a register (or spill)
22 /// completed, and we can't alter it just to make debug-info complete. Thus:
29 /// another value), then re-compute an SSA-form representation of the
30 /// MachineFunction, using value propagation to eliminate any un-necessary
37 /// any un-necessary PHIs. This gives us a map of each variable to the value
43 /// After which we can marry-up variable values with a location, and emit
51 /// is proportional to the working-set size of the function, which the compiler
79 //===----------------------------------------------------------------------===//
105 #include "llvm/Config/llvm-config.h"
141 static cl::opt<bool> EmulateOldLDV("emulate-old-livedebugvalues", cl::Hidden,
150 // the developer has hundreds of variables live at the same time that they're
151 // carefully thinking about -- instead, they probably autogenerated the code.
155 StackWorkingSetLimit("livedebugvalues-max-stack-slots", cl::Hidden,
156 cl::desc("livedebugvalues-stack-ws-limit"),
163 /// specifying block live-in locations and transfers within blocks.
165 /// Operating on a per-block basis, this class takes a (pre-loaded) MLocTracker
166 /// and must be initialized with the set of variable values that are live-in to
168 /// out variable locations for the live-in variable values (if there _is_ a
173 /// This is where debug use-before-defs would be resolved: a variable with an
175 /// value becomes available. Or, we could detect clobbers and re-specify the
181 /// This machine location tracker is assumed to always contain the up-to-date
194 MachineBasicBlock *MBB; /// non-null if we should insert after.
201 /// qualifying meta-information needed to construct a concrete DBG_VALUE-like
224 /// Local cache of what-value-is-in-what-LocIdx. Used to identify differences
232 /// VarLocs[Idx] != MTracker->LocIdxToIDNum[Idx].
243 /// Record of a use-before-def: created when a value that's live-in to the
265 /// collection prevents the use-before-def materializing.
283 unsigned Reg = MTracker->LocIdxToLocID[L]; in isCalleeSaved()
284 if (Reg >= MTracker->NumRegs) in isCalleeSaved()
294 // slots generally live longer than callee-saved registers which generally
295 // live longer than non-callee-saved registers. The minimum value of 0
338 if (MTracker->isSpill(L)) in getLocQualityIfBetter()
349 /// For a variable \p Var with the live-in value \p Value, attempts to resolve
354 /// \p MBB is the basic block that we are loading the live-in value for.
355 /// \p DbgOpStore is the map containing the DbgOpID->DbgOp mapping needed to
396 ValuesPreferredLoc->first == Num); in loadVarInloc()
398 if (ValuesPreferredLoc->second.isIllegal()) { in loadVarInloc()
400 // use-before-def to be resolved as we step through the block. in loadVarInloc()
414 // live range. in loadVarInloc()
415 LocIdx M = ValuesPreferredLoc->second.getLoc(); in loadVarInloc()
438 Result.first->second = NewValue; in loadVarInloc()
441 std::make_pair(VarID, &*MTracker->emitLoc(ResolvedDbgOps, Var, DILoc, in loadVarInloc()
445 /// Load object with live-in variable values. \p mlocs contains the live-in
446 /// values in each machine location, while \p vlocs the live-in variable
447 /// values. This method picks variable locations for the live-in variables,
466 // Initialized the preferred-location map with illegal locations, to be in loadInlocs()
479 // Produce a map of value numbers to the current machine locs they live in loadInlocs()
482 for (auto Location : MTracker->locations()) { in loadInlocs()
493 if (VIt == ValueToLoc.end() || VIt->first != VNum) in loadInlocs()
496 auto &Previous = VIt->second; in loadInlocs()
522 /// processed, check whether it defines a variable value in a use-before-def.
536 for (auto &Use : MIt->second) { in checkInstForNewValues()
555 for (auto Location : MTracker->locations()) { in checkInstForNewValues()
564 auto &Previous = VIt->second; in checkInstForNewValues()
575 for (auto &Use : MIt->second) { in checkInstForNewValues()
586 LocIdx NewLoc = ValueToLoc.find(Op.ID)->second.getLoc(); in checkInstForNewValues()
601 Use.VarID, MTracker->emitLoc(DbgOps, Var, DILoc, Use.Properties))); in checkInstForNewValues()
613 if (MBB && Pos == MBB->begin()) in flushDbgValues()
614 BundleStart = MBB->instr_begin(); in flushDbgValues()
616 BundleStart = getBundleStart(Pos->getIterator()); in flushDbgValues()
624 if (!Var.getVariable()->isParameter()) in isEntryValueVariable()
630 if (Expr->getNumElements() > 0 && !Expr->isDeref()) in isEntryValueVariable()
637 // Must be in entry block (block number zero), and be a PHI / live-in value. in isEntryValueValue()
642 if (MTracker->isSpill(Val.getLoc())) in isEntryValueValue()
645 Register SP = TLI->getStackPointerRegisterToSaveRestore(); in isEntryValueValue()
647 Register Reg = MTracker->LocIdxToLocID[Val.getLoc()]; in isEntryValueValue()
663 // If this debug value can be converted to be non-variadic, then do so; in recoverAsEntryValue()
685 Register Reg = MTracker->LocIdxToLocID[Num.getLoc()]; in recoverAsEntryValue()
695 MI.getDebugLoc()->getInlinedAt()); in redefVar()
699 // Ignore non-register locations, we don't transfer those. in redefVar()
705 for (LocIdx Loc : It->second.loc_indices()) in redefVar()
709 // Any use-before-defs no longer apply. in redefVar()
719 LocIdx NewLoc = MTracker->getRegMLoc(Reg); in redefVar()
735 MI.getDebugLoc()->getInlinedAt()); in redefVar()
737 // Any use-before-defs no longer apply. in redefVar()
743 for (LocIdx Loc : It->second.loc_indices()) in redefVar()
761 // Check whether our local copy of values-by-location in #VarLocs is out in redefVar()
764 if (MTracker->readMLoc(NewLoc) != VarLocs[NewLoc.asU64()]) { in redefVar()
768 for (LocIdx Loc : LostVLocIt->second.loc_indices()) { in redefVar()
783 VarLocs[NewLoc.asU64()] = MTracker->readMLoc(NewLoc); in redefVar()
793 It->second.Ops.assign(NewLocs); in redefVar()
794 It->second.Properties = Properties; in redefVar()
826 for (auto Loc : MTracker->locations()) in clobberMloc()
834 for (DebugVariableID VarID : ActiveMLocIt->second) { in clobberMloc()
835 auto &Prop = ActiveVLocs.find(VarID)->second.Properties; in clobberMloc()
845 // MLoc is dead, so end their existing MLoc->Var mappings as well. in clobberMloc()
847 for (DebugVariableID VarID : ActiveMLocIt->second) { in clobberMloc()
849 // Re-state the variable location: if there's no replacement then NewLoc in clobberMloc()
852 const DbgValueProperties &Properties = ActiveVLocIt->second.Properties; in clobberMloc()
854 // Produce the new list of debug ops - an empty list if no new location in clobberMloc()
855 // was found, or the existing list with the substitution MLoc -> NewLoc in clobberMloc()
862 DbgOps.insert(DbgOps.begin(), ActiveVLocIt->second.Ops.size(), in clobberMloc()
864 replace_copy(ActiveVLocIt->second.Ops, DbgOps.begin(), OldOp, NewOp); in clobberMloc()
869 VarID, &*MTracker->emitLoc(DbgOps, Var, DILoc, Properties))); in clobberMloc()
874 for (LocIdx Loc : ActiveVLocIt->second.loc_indices()) { in clobberMloc()
880 ActiveVLocIt->second.Ops = DbgOps; in clobberMloc()
892 LostMLocIt->second.erase(LocVarIt.second); in clobberMloc()
898 VarLocs[NewLoc->asU64()] = OldValue; in clobberMloc()
903 ActiveMLocIt->second.clear(); in clobberMloc()
915 if (VarLocs[Src.asU64()] != MTracker->readMLoc(Src)) in transferMlocs()
919 //^^^ Legitimate scenario on account of un-clobbered slot being assigned to? in transferMlocs()
934 std::replace(ActiveVLocIt->second.Ops.begin(), in transferMlocs()
935 ActiveVLocIt->second.Ops.end(), SrcOp, DstOp); in transferMlocs()
938 MachineInstr *MI = MTracker->emitLoc(ActiveVLocIt->second.Ops, Var, DILoc, in transferMlocs()
939 ActiveVLocIt->second.Properties); in transferMlocs()
954 DebugLoc DL = DILocation::get(Var.getVariable()->getContext(), 0, 0, in emitMOLoc()
955 Var.getVariable()->getScope(), in emitMOLoc()
957 auto MIB = BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE)); in emitMOLoc()
969 //===----------------------------------------------------------------------===//
971 //===----------------------------------------------------------------------===//
974 ValueIDNum ValueIDNum::TombstoneValue = {UINT_MAX, UINT_MAX, UINT_MAX - 1};
981 dbgs() << MTrack->LocIdxToName(Loc); in dump()
988 dbgs() << MTrack->IDAsString(ID); in dump()
995 OpStore->find(*this).dump(MTrack); in dump()
1043 // Build some common stack positions -- full registers being spilt to the in MLocTracker()
1061 // Some subregs have -1, -2 and so forth fed into their fields, to mean in MLocTracker()
1099 if (MaskPair.first->clobbersPhysReg(ID)) { in trackRegister()
1115 // relied upon -- we represent this by giving it a new value. in writeRegMask()
1119 if (ID < NumRegs && !SPAliases.count(ID) && MO->clobbersPhysReg(ID)) in writeRegMask()
1144 // Initialize to PHI value; corresponds to the location's live-in value in getOrTrackSpillLoc()
1156 ID -= NumRegs; in LocIdxToName()
1177 dbgs() << LocIdxToName(Location.Idx) << " --> " << DefName << "\n"; in dump()
1210 auto GetRegOp = [](unsigned Reg) -> MachineOperand { in emitLoc()
1256 // TODO: support variables that are located in spill slots, with non-zero in emitLoc()
1260 // Accept no-subregister slots and subregisters where the offset is zero. in emitLoc()
1285 unsigned VariableSizeInBits = Fragment->SizeInBits; in emitLoc()
1286 if (VariableSizeInBits != ValueSizeInBits || Expr->isComplex()) in emitLoc()
1288 } else if (auto Size = Var.getVariable()->getSizeInBits()) { in emitLoc()
1302 assert(!Expr->isImplicit()); in emitLoc()
1304 } else if (UseDerefSize && Expr->isSingleLocationExpression()) { in emitLoc()
1313 } else if (Expr->isComplex() || Properties.IsVariadic) { in emitLoc()
1332 // Non-empty, non-stack slot, must be a plain register. in emitLoc()
1344 unsigned Reg = MTracker->LocIdxToLocID[L]; in isCalleeSaved()
1354 //===----------------------------------------------------------------------===//
1356 //===----------------------------------------------------------------------===//
1368 const PseudoSourceValue *PVal = (*MMOI)->getPseudoValue(); in extractSpillBaseRegAndOffset()
1369 assert(PVal->kind() == PseudoSourceValue::FixedStack && in extractSpillBaseRegAndOffset()
1371 int FI = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex(); in extractSpillBaseRegAndOffset()
1374 StackOffset Offset = TFI->getFrameIndexReference(*MBB->getParent(), FI, Reg); in extractSpillBaseRegAndOffset()
1375 return MTracker->getOrTrackSpillLoc({Reg, Offset}); in extractSpillBaseRegAndOffset()
1384 // Where in the stack slot is this value defined -- i.e., what size of value in findLocationForMemOperand()
1389 LocationSize SizeInBits = MemOperand->getSizeInBits(); in findLocationForMemOperand()
1393 auto IdxIt = MTracker->StackSlotIdxes.find({SizeInBits.getValue(), 0}); in findLocationForMemOperand()
1394 if (IdxIt == MTracker->StackSlotIdxes.end()) in findLocationForMemOperand()
1399 unsigned SpillID = MTracker->getSpillIDWithIdx(*SpillLoc, IdxIt->second); in findLocationForMemOperand()
1400 return MTracker->getSpillMLoc(SpillID); in findLocationForMemOperand()
1409 assert(MI.getDebugVariable()->isValidLocationForIntrinsic(MI.getDebugLoc()) && in transferDebugValue()
1410 "Expected inlined-at fields to agree"); in transferDebugValue()
1422 (void)MTracker->readReg(MO.getReg()); in transferDebugValue()
1436 DebugOps.push_back(DbgOpStore.insert(MTracker->readReg(MO.getReg()))); in transferDebugValue()
1444 VTracker->defVar(MI, DbgValueProperties(MI), DebugOps); in transferDebugValue()
1450 TTracker->redefVar(MI); in transferDebugValue()
1461 const MachineFunction &MF = *MI.getParent()->getParent(); in getValueForInstrRef()
1470 LowerBoundIt->Src == SoughtSub.Src) { in getValueForInstrRef()
1471 std::tie(InstNo, OpNo) = LowerBoundIt->Dest; in getValueForInstrRef()
1472 SoughtSub.Src = LowerBoundIt->Dest; in getValueForInstrRef()
1473 if (unsigned Subreg = LowerBoundIt->Subreg) in getValueForInstrRef()
1478 // Default machine value number is <None> -- if no instruction defines in getValueForInstrRef()
1487 const MachineInstr &TargetInstr = *InstrIt->second.first; in getValueForInstrRef()
1488 uint64_t BlockNo = TargetInstr.getParent()->getNumber(); in getValueForInstrRef()
1496 NewID = ValueIDNum(BlockNo, InstrIt->second.second, *L); in getValueForInstrRef()
1498 // Permit the debug-info to be completely wrong: identifying a nonexistant in getValueForInstrRef()
1500 // unexpected happened during optimisation. Broken debug-info, however, in getValueForInstrRef()
1501 // shouldn't crash the compiler -- instead leave the variable value as in getValueForInstrRef()
1507 unsigned LocID = MTracker->getLocID(MO.getReg()); in getValueForInstrRef()
1508 LocIdx L = MTracker->LocIDToLocIdx[LocID]; in getValueForInstrRef()
1509 NewID = ValueIDNum(BlockNo, InstrIt->second.second, L); in getValueForInstrRef()
1519 } else if (PHIIt != DebugPHINumToValue.end() && PHIIt->InstrNum == InstNo) { in getValueForInstrRef()
1523 NewID = resolveDbgPHIs(*MI.getParent()->getParent(), *MLiveOuts, *MLiveIns, in getValueForInstrRef()
1529 // CALL64 @foo, implicit-def $rax in getValueForInstrRef()
1545 unsigned ThisSize = TRI->getSubRegIdxSize(Subreg); in getValueForInstrRef()
1546 unsigned ThisOffset = TRI->getSubRegIdxOffset(Subreg); in getValueForInstrRef()
1555 LocIdx L = NewID->getLoc(); in getValueForInstrRef()
1556 if (NewID && !MTracker->isSpill(L)) { in getValueForInstrRef()
1559 Register Reg = MTracker->LocIdxToLocID[L]; in getValueForInstrRef()
1561 for (const auto *TRCI : TRI->regclasses()) in getValueForInstrRef()
1562 if (TRCI->contains(Reg)) in getValueForInstrRef()
1568 unsigned MainRegSize = TRI->getRegSizeInBits(*TRC); in getValueForInstrRef()
1572 for (MCPhysReg SR : TRI->subregs(Reg)) { in getValueForInstrRef()
1573 unsigned Subreg = TRI->getSubRegIndex(Reg, SR); in getValueForInstrRef()
1574 unsigned SubregSize = TRI->getSubRegIdxSize(Subreg); in getValueForInstrRef()
1575 unsigned SubregOffset = TRI->getSubRegIdxOffset(Subreg); in getValueForInstrRef()
1586 // Re-state the value as being defined within the subregister in getValueForInstrRef()
1588 LocIdx NewLoc = MTracker->lookupOrTrackRegister(NewReg); in getValueForInstrRef()
1589 NewID = ValueIDNum(NewID->getBlock(), NewID->getInst(), NewLoc); in getValueForInstrRef()
1615 const DILocation *InlinedAt = DebugLoc->getInlinedAt(); in transferDebugInstrRef()
1616 assert(Var->isValidLocationForIntrinsic(DebugLoc) && in transferDebugInstrRef()
1617 "Expected inlined-at fields to agree"); in transferDebugInstrRef()
1637 // Default machine value number is <None> -- if no instruction defines in transferDebugInstrRef()
1657 VTracker->defVar(MI, Properties, DbgOpIDs); in transferDebugInstrRef()
1674 // Initialized the preferred-location map with illegal locations, to be in transferDebugInstrRef()
1683 for (auto Location : MTracker->locations()) { in transferDebugInstrRef()
1685 ValueIDNum ID = MTracker->readMLoc(CurL); in transferDebugInstrRef()
1689 auto &Previous = FoundLocs.find(ID)->second; in transferDebugInstrRef()
1693 TTracker->getLocQualityIfBetter(CurL, Previous.getQuality()); in transferDebugInstrRef()
1710 LocIdx FoundLoc = FoundLocs.find(DbgOp.ID)->second.getLoc(); in transferDebugInstrRef()
1718 TTracker->redefVar(MI, Properties, NewLocs); in transferDebugInstrRef()
1721 // later instructions in this block, this is a block-local use-before-def. in transferDebugInstrRef()
1740 TTracker->addUseBeforeDef(VID, {MI.getDebugExpression(), false, true}, in transferDebugInstrRef()
1748 // (XXX -- could morph the DBG_INSTR_REF in the future). in transferDebugInstrRef()
1750 MTracker->emitLoc(NewLocs, V, MI.getDebugLoc().get(), Properties); in transferDebugInstrRef()
1753 TTracker->PendingDbgValues.push_back(std::make_pair(ID, DbgMI)); in transferDebugInstrRef()
1754 TTracker->flushDbgValues(MI.getIterator(), nullptr); in transferDebugInstrRef()
1771 auto EmitBadPHI = [this, &MI, InstrNum]() -> bool { in transferDebugPHI()
1785 ValueIDNum Num = MTracker->readReg(Reg); in transferDebugPHI()
1787 {InstrNum, MI.getParent(), Num, MTracker->lookupOrTrackRegister(Reg)}); in transferDebugPHI()
1792 MTracker->lookupOrTrackRegister(*RAI); in transferDebugPHI()
1799 if (MFI->isDeadObjectIndex(FI)) in transferDebugPHI()
1804 StackOffset Offs = TFI->getFrameIndexReference(*MI.getMF(), FI, Base); in transferDebugPHI()
1806 std::optional<SpillLocationNo> SpillNo = MTracker->getOrTrackSpillLoc(SL); in transferDebugPHI()
1813 // Any stack location DBG_PHI should have an associate bit-size. in transferDebugPHI()
1817 unsigned SpillID = MTracker->getLocID(*SpillNo, {slotBitSize, 0}); in transferDebugPHI()
1818 LocIdx SpillLoc = MTracker->getSpillMLoc(SpillID); in transferDebugPHI()
1819 ValueIDNum Result = MTracker->readMLoc(SpillLoc); in transferDebugPHI()
1826 // we're being fed illegal debug-info. Record an empty PHI, so that any in transferDebugPHI()
1843 // the register is live, without be specific about it's value. So define in transferRegisterDef()
1845 ValueIDNum Num = MTracker->readReg(MI.getOperand(0).getReg()); in transferRegisterDef()
1846 // Has a legitimate value -> ignore the implicit def. in transferRegisterDef()
1865 auto IgnoreSPAlias = [this, &MI, CallChangesSP](Register R) -> bool { in transferRegisterDef()
1868 return MI.isCall() && MTracker->SPAliases.count(R); in transferRegisterDef()
1893 MTracker->defReg(DeadReg, CurBB, CurInst); in transferRegisterDef()
1896 MTracker->writeRegMask(MO, CurBB, CurInst); in transferRegisterDef()
1902 for (unsigned int I = 0; I < MTracker->NumSlotIdxes; ++I) { in transferRegisterDef()
1903 unsigned SpillID = MTracker->getSpillIDWithIdx(*SpillNo, I); in transferRegisterDef()
1904 LocIdx L = MTracker->getSpillMLoc(SpillID); in transferRegisterDef()
1905 MTracker->setMLoc(L, ValueIDNum(CurBB, CurInst, L)); in transferRegisterDef()
1919 LocIdx Loc = MTracker->lookupOrTrackRegister(DeadReg); in transferRegisterDef()
1920 TTracker->clobberMloc(Loc, MI.getIterator(), false); in transferRegisterDef()
1926 for (auto L : MTracker->locations()) { in transferRegisterDef()
1928 if (MTracker->isSpill(L.Idx)) in transferRegisterDef()
1931 Register Reg = MTracker->LocIdxToLocID[L.Idx]; in transferRegisterDef()
1936 if (MO->clobbersPhysReg(Reg)) in transferRegisterDef()
1937 TTracker->clobberMloc(L.Idx, MI.getIterator(), false); in transferRegisterDef()
1945 for (unsigned int I = 0; I < MTracker->NumSlotIdxes; ++I) { in transferRegisterDef()
1946 unsigned SpillID = MTracker->getSpillIDWithIdx(*SpillNo, I); in transferRegisterDef()
1947 LocIdx L = MTracker->getSpillMLoc(SpillID); in transferRegisterDef()
1948 TTracker->clobberMloc(L, MI.getIterator(), true); in transferRegisterDef()
1955 // In all circumstances, re-def all aliases. It's definitely a new value now. in performCopy()
1957 MTracker->defReg(*RAI, CurBB, CurInst); in performCopy()
1959 ValueIDNum SrcValue = MTracker->readReg(SrcRegNum); in performCopy()
1960 MTracker->setReg(DstRegNum, SrcValue); in performCopy()
1966 unsigned DstSubReg = TRI->getSubReg(DstRegNum, SubRegIdx); in performCopy()
1971 // have been def'd when the super-reg was, the latter might not be tracked in performCopy()
1975 LocIdx SrcL = MTracker->lookupOrTrackRegister(SrcSubReg); in performCopy()
1976 LocIdx DstL = MTracker->lookupOrTrackRegister(DstSubReg); in performCopy()
1979 ValueIDNum CpyValue = MTracker->readReg(SrcSubReg); in performCopy()
1981 MTracker->setReg(DstSubReg, CpyValue); in performCopy()
1992 // Reject any memory operand that's aliased -- we can't guarantee its value. in isSpillInstruction()
1994 const PseudoSourceValue *PVal = (*MMOI)->getPseudoValue(); in isSpillInstruction()
1995 if (PVal->isAliased(MFI)) in isSpillInstruction()
2011 Reg = TII->isStoreToStackSlotPostFE(MI, FI); in isLocationSpill()
2031 // XXX -- it's too difficult to implement VarLocBasedImpl's stack location in transferSpillOrRestoreInst()
2039 int DummyFI = -1; in transferSpillOrRestoreInst()
2040 if (!TII->isStoreToStackSlotPostFE(MI, DummyFI) && in transferSpillOrRestoreInst()
2041 !TII->isLoadFromStackSlotPostFE(MI, DummyFI)) in transferSpillOrRestoreInst()
2052 if (!TII->isStoreToStackSlotPostFE(MI, FIDummy) && in transferSpillOrRestoreInst()
2053 !TII->isLoadFromStackSlotPostFE(MI, FIDummy)) in transferSpillOrRestoreInst()
2060 // Un-set this location and clobber, so that earlier locations don't in transferSpillOrRestoreInst()
2062 for (unsigned SlotIdx = 0; SlotIdx < MTracker->NumSlotIdxes; ++SlotIdx) { in transferSpillOrRestoreInst()
2063 unsigned SpillID = MTracker->getSpillIDWithIdx(*Loc, SlotIdx); in transferSpillOrRestoreInst()
2064 std::optional<LocIdx> MLoc = MTracker->getSpillMLoc(SpillID); in transferSpillOrRestoreInst()
2068 // We need to over-write the stack slot with something (here, a def at in transferSpillOrRestoreInst()
2071 // location and re-installing it in the same place. in transferSpillOrRestoreInst()
2073 MTracker->setMLoc(*MLoc, Def); in transferSpillOrRestoreInst()
2075 TTracker->clobberMloc(*MLoc, MI.getIterator()); in transferSpillOrRestoreInst()
2086 auto ReadValue = MTracker->readReg(SrcReg); in transferSpillOrRestoreInst()
2087 LocIdx DstLoc = MTracker->getSpillMLoc(SpillID); in transferSpillOrRestoreInst()
2088 MTracker->setMLoc(DstLoc, ReadValue); in transferSpillOrRestoreInst()
2091 LocIdx SrcLoc = MTracker->getRegMLoc(SrcReg); in transferSpillOrRestoreInst()
2092 TTracker->transferMlocs(SrcLoc, DstLoc, MI.getIterator()); in transferSpillOrRestoreInst()
2097 for (MCPhysReg SR : TRI->subregs(Reg)) { in transferSpillOrRestoreInst()
2099 (void)MTracker->lookupOrTrackRegister(SR); in transferSpillOrRestoreInst()
2100 unsigned SubregIdx = TRI->getSubRegIndex(Reg, SR); in transferSpillOrRestoreInst()
2101 unsigned SpillID = MTracker->getLocID(Loc, SubregIdx); in transferSpillOrRestoreInst()
2106 unsigned Size = TRI->getRegSizeInBits(Reg, *MRI); in transferSpillOrRestoreInst()
2107 unsigned SpillID = MTracker->getLocID(Loc, {Size, 0}); in transferSpillOrRestoreInst()
2122 MTracker->defReg(*RAI, CurBB, CurInst); in transferSpillOrRestoreInst()
2127 LocIdx SrcIdx = MTracker->getSpillMLoc(SpillID); in transferSpillOrRestoreInst()
2128 auto ReadValue = MTracker->readMLoc(SrcIdx); in transferSpillOrRestoreInst()
2129 MTracker->setReg(DestReg, ReadValue); in transferSpillOrRestoreInst()
2132 for (MCPhysReg SR : TRI->subregs(Reg)) { in transferSpillOrRestoreInst()
2133 unsigned Subreg = TRI->getSubRegIndex(Reg, SR); in transferSpillOrRestoreInst()
2134 unsigned SpillID = MTracker->getLocID(*Loc, Subreg); in transferSpillOrRestoreInst()
2139 unsigned Size = TRI->getRegSizeInBits(Reg, *MRI); in transferSpillOrRestoreInst()
2140 unsigned SpillID = MTracker->getLocID(*Loc, {Size, 0}); in transferSpillOrRestoreInst()
2147 auto DestSrc = TII->isCopyLikeInstr(MI); in transferRegisterCopy()
2151 const MachineOperand *DestRegOp = DestSrc->Destination; in transferRegisterCopy()
2152 const MachineOperand *SrcRegOp = DestSrc->Source; in transferRegisterCopy()
2154 Register SrcReg = SrcRegOp->getReg(); in transferRegisterCopy()
2155 Register DestReg = DestRegOp->getReg(); in transferRegisterCopy()
2174 if (EmulateOldLDV && !SrcRegOp->isKill()) in transferRegisterCopy()
2183 LocIdx ClobberedLoc = MTracker->getRegMLoc(*RAI); in transferRegisterCopy()
2184 auto MLocIt = TTracker->ActiveMLocs.find(ClobberedLoc); in transferRegisterCopy()
2187 if (MLocIt == TTracker->ActiveMLocs.end() || MLocIt->second.empty()) in transferRegisterCopy()
2189 ValueIDNum Value = MTracker->readReg(*RAI); in transferRegisterCopy()
2202 TTracker->clobberMloc(LocVal.first, LocVal.second, MI.getIterator(), false); in transferRegisterCopy()
2209 if (TTracker && isCalleeSavedReg(DestReg) && SrcRegOp->isKill()) in transferRegisterCopy()
2210 TTracker->transferMlocs(MTracker->getRegMLoc(SrcReg), in transferRegisterCopy()
2211 MTracker->getRegMLoc(DestReg), MI.getIterator()); in transferRegisterCopy()
2215 MTracker->defReg(SrcReg, CurBB, CurInst); in transferRegisterCopy()
2222 /// the data-flow stage from "Find any overlapping fragments" to "Check if the
2223 /// known-to-overlap fragments are present".
2229 MI.getDebugLoc()->getInlinedAt()); in accumulateFragmentMap()
2252 auto &ThisFragmentsOverlaps = IsInOLapMap.first->second; in accumulateFragmentMap()
2253 auto &AllSeenFragments = SeenIt->second; in accumulateFragmentMap()
2269 ASeenFragmentsOverlaps->second.push_back(ThisFragment); in accumulateFragmentMap()
2310 unsigned BVWords = MachineOperand::getRegMaskSize(TRI->getNumRegs()); in produceMLocTransferFunction()
2312 BV.resize(TRI->getNumRegs(), true); in produceMLocTransferFunction()
2322 // production only, this signifies the live-in value to the block. in produceMLocTransferFunction()
2323 MTracker->reset(); in produceMLocTransferFunction()
2324 MTracker->setMPhis(CurBB); in produceMLocTransferFunction()
2352 // any machine location has the live-in phi value from the start of the in produceMLocTransferFunction()
2353 // block, it's live-through and doesn't need recording in the transfer in produceMLocTransferFunction()
2355 for (auto Location : MTracker->locations()) { in produceMLocTransferFunction()
2361 // Insert-or-update. in produceMLocTransferFunction()
2365 Result.first->second = P; in produceMLocTransferFunction()
2370 for (auto &P : MTracker->Masks) { in produceMLocTransferFunction()
2371 BlockMasks[CurBB].clearBitsNotInMask(P.first->getRegMask(), BVWords); in produceMLocTransferFunction()
2376 BitVector UsedRegs(TRI->getNumRegs()); in produceMLocTransferFunction()
2377 for (auto Location : MTracker->locations()) { in produceMLocTransferFunction()
2378 unsigned ID = MTracker->LocIdxToLocID[Location.Idx]; in produceMLocTransferFunction()
2380 if (ID >= TRI->getNumRegs() || MTracker->SPAliases.count(ID)) in produceMLocTransferFunction()
2385 // Check that any regmask-clobber of a register that gets tracked, is not in produceMLocTransferFunction()
2386 // live-through in the transfer function. It needs to be clobbered at the in produceMLocTransferFunction()
2396 unsigned ID = MTracker->getLocID(Bit); in produceMLocTransferFunction()
2397 LocIdx Idx = MTracker->LocIDToLocIdx[ID]; in produceMLocTransferFunction()
2409 ValueIDNum &ValueID = Result.first->second; in produceMLocTransferFunction()
2411 // It was left as live-through. Set it to clobbered. in produceMLocTransferFunction()
2424 // Handle value-propagation when control flow merges on entry to a block. For in mlocJoin()
2435 return BBToOrder.find(A)->second < BBToOrder.find(B)->second; in mlocJoin()
2441 // FIXME: We don't use assert here to prevent instr-ref-unreachable.mir in mlocJoin()
2452 for (auto Location : MTracker->locations()) { in mlocJoin()
2455 // Pick out the first predecessors live-out value for this location. It's in mlocJoin()
2460 // propagate the first live-in value into this block. in mlocJoin()
2469 // We're now examining a PHI to see whether it's un-necessary. Loop around in mlocJoin()
2470 // the other live-in values and test whether they're all the same. in mlocJoin()
2484 // Live-out of a predecessor disagrees with the first predecessor. in mlocJoin()
2488 // No disagreement? No PHI. Otherwise, leave the PHI in live-ins. in mlocJoin()
2506 // * Most indexes with non-zero offset will end up being interference units in findStackIndexInterference()
2510 // We can rely on a single-byte stack index existing already, because we in findStackIndexInterference()
2512 auto It = MTracker->StackSlotIdxes.find({8, 0}); in findStackIndexInterference()
2513 assert(It != MTracker->StackSlotIdxes.end()); in findStackIndexInterference()
2514 Slots.push_back(It->second); in findStackIndexInterference()
2516 // Find anything that has a non-zero offset and add that too. in findStackIndexInterference()
2517 for (auto &Pair : MTracker->StackSlotIdxes) { in findStackIndexInterference()
2541 for (auto Location : MTracker->locations()) { in placeMLocPHIs()
2543 if (MTracker->isSpill(L)) { in placeMLocPHIs()
2544 StackSlots.insert(MTracker->locIDToSpill(MTracker->LocIdxToLocID[L])); in placeMLocPHIs()
2548 Register R = MTracker->LocIdxToLocID[L]; in placeMLocPHIs()
2551 for (MCRegUnit Unit : TRI->regunits(R.asMCReg())) { in placeMLocPHIs()
2553 if (!MTracker->isRegisterTracked(*URoot)) { in placeMLocPHIs()
2580 const auto &TransferFunc = MLocTransfer[MBB->getNumber()]; in placeMLocPHIs()
2585 // The entry block defs the location too: it's the live-in / argument value. in placeMLocPHIs()
2586 // Only insert if there are other defs though; everything is trivially live in placeMLocPHIs()
2599 MInLocs[*MBB][L.asU64()] = ValueIDNum(MBB->getNumber(), 0, L); in placeMLocPHIs()
2605 // Install those PHI values into the live-in value array. in placeMLocPHIs()
2613 unsigned SpillID = MTracker->getSpillIDWithIdx(Slot, Idx); in placeMLocPHIs()
2614 LocIdx L = MTracker->getSpillMLoc(SpillID); in placeMLocPHIs()
2620 std::tie(Size, Offset) = MTracker->StackIdxesToPos[Idx]; in placeMLocPHIs()
2621 for (auto &Pair : MTracker->StackSlotIdxes) { in placeMLocPHIs()
2627 unsigned ThisID = MTracker->getSpillIDWithIdx(Slot, Pair.second); in placeMLocPHIs()
2628 LocIdx ThisL = MTracker->getSpillMLoc(ThisID); in placeMLocPHIs()
2636 LocIdx L = MTracker->lookupOrTrackRegister(R); in placeMLocPHIs()
2639 // Install those PHI values into the live-in value array. in placeMLocPHIs()
2644 // Super-registers that are "above" the largest register read/written by in placeMLocPHIs()
2646 if (!MTracker->isRegisterTracked(*RAI)) in placeMLocPHIs()
2649 LocIdx AliasLoc = MTracker->lookupOrTrackRegister(*RAI); in placeMLocPHIs()
2677 for (auto Location : MTracker->locations()) in buildMLocValueMap()
2681 MTracker->reset(); in buildMLocValueMap()
2684 // any machine-location that isn't live-through a block to be def'd in that in buildMLocValueMap()
2694 // code. Propagating values allows us to identify such un-necessary PHIs and in buildMLocValueMap()
2703 CurBB = MBB->getNumber(); in buildMLocValueMap()
2716 // Load the current set of live-ins into MLocTracker. in buildMLocValueMap()
2717 MTracker->loadFromArray(MInLocs[*MBB], CurBB); in buildMLocValueMap()
2720 // a live-in value. Evaluate each element, and store to "ToRemap". in buildMLocValueMap()
2724 // This is a movement of whatever was live in. Read it. in buildMLocValueMap()
2725 ValueIDNum NewID = MTracker->readMLoc(P.second.getLoc()); in buildMLocValueMap()
2735 // transforms the contents of the MLocTracker into the live-outs. in buildMLocValueMap()
2737 MTracker->setMLoc(P.first, P.second); in buildMLocValueMap()
2739 // Now copy out-locs from mloc tracker into out-loc vector, checking in buildMLocValueMap()
2743 for (auto Location : MTracker->locations()) { in buildMLocValueMap()
2748 MTracker->reset(); in buildMLocValueMap()
2750 // No need to examine successors again if out-locs didn't change. in buildMLocValueMap()
2754 // All successors should be visited: put any back-edges on the pending in buildMLocValueMap()
2755 // list for the next pass-through, and any other successors to be in buildMLocValueMap()
2757 for (auto *s : MBB->successors()) { in buildMLocValueMap()
2758 // Does branching to this successor represent a back-edge? in buildMLocValueMap()
2779 // Once all the live-ins don't change on mlocJoin(), we've eliminated all in buildMLocValueMap()
2790 IDFCalculatorBase<MachineBasicBlock, false> IDF(DomTree->getBase()); in BlockPHIPlacement()
2813 const DbgValue &FirstValue = *FirstValueIt->second; in pickVPHILoc()
2820 const DbgValue &OutVal = *OutValIt->second; in pickVPHILoc()
2822 // No-values cannot have locations we can join on. in pickVPHILoc()
2844 // We can never join constant ops - the ops must either both be equal in pickVPHILoc()
2845 // constant ops or non-const ops. in pickVPHILoc()
2858 // already-agreed value. in pickVPHILoc()
2882 // Collect a set of locations from predecessor where its live-out value can in pickOperandPHILoc()
2885 unsigned NumLocs = MTracker->getNumLocs(); in pickOperandPHILoc()
2890 const DbgValue &OutVal = *OutValIt->second; in pickOperandPHILoc()
2898 // If the live-in value is a def, find the locations where that value is in pickOperandPHILoc()
2904 // Search the live-outs of the predecessor for the specified value. in pickOperandPHILoc()
2912 // a value that's live-through the whole loop. (It has to be a backedge, in pickOperandPHILoc()
2915 // locations feed back into themselves. Therefore, add all self-looping in pickOperandPHILoc()
2916 // machine-value PHI locations. in pickOperandPHILoc()
2945 // Return a PHI-value-number for the found location. in pickOperandPHILoc()
2969 // live-out values. in vlocJoin()
2981 // All Live-outs will have been initialized. in vlocJoin()
2982 DbgValue &OutLoc = *VLOCOutLocs.find(p)->second; in vlocJoin()
2984 // Keep track of where back-edges begin in the Values vector. Relies on in vlocJoin()
2994 // value, then give up immediately. It's not safe to produce a live-in in vlocJoin()
2999 // All (non-entry) blocks have at least one non-backedge predecessor. in vlocJoin()
3004 // If the old live-in value is not a PHI then either a) no PHI is needed in vlocJoin()
3016 // non-constants. in vlocJoin()
3018 if (!V.second->Properties.isJoinable(FirstVal.Properties)) in vlocJoin()
3020 if (V.second->Kind == DbgValue::NoVal) in vlocJoin()
3022 if (!V.second->hasJoinableLocOps(FirstVal)) in vlocJoin()
3032 // If both values are not equal but have equal non-empty IDs then they refer in vlocJoin()
3035 if (V.second->hasIdenticalValidLocOps(FirstVal)) in vlocJoin()
3039 if (V.second->Kind == DbgValue::VPHI && in vlocJoin()
3040 V.second->BlockNo == MBB.getNumber() && in vlocJoin()
3048 // No disagreement -> live-through value. in vlocJoin()
3068 // Get the set of "normal" in-lexical-scope blocks. in getBlocksForScope()
3083 // Perform a depth-first-search to enumerate those blocks. in getBlocksForScope()
3085 // Depth-first-search state: each node is a block and which successor in getBlocksForScope()
3093 for (auto *succ : MBB->successors()) { in getBlocksForScope()
3099 DFS.push_back({succ, succ->succ_begin()}); in getBlocksForScope()
3107 if (CurSucc == CurBB->succ_end()) { in getBlocksForScope()
3116 DFS.push_back({*CurSucc, (*CurSucc)->succ_begin()}); in getBlocksForScope()
3153 // that then produces output differences from original-live-debug-values, in buildVLocValueMap()
3158 // Convert a const set to a non-const set. LexicalScopes in buildVLocValueMap()
3166 // order-numbers and map back to MBB pointers later, to avoid repeated in buildVLocValueMap()
3177 // Allocate some vectors for storing the live ins and live outs. Large. in buildVLocValueMap()
3182 // Initialize all values to start as NoVals. This signifies "it's live in buildVLocValueMap()
3191 // Produce by-MBB indexes of live-in/live-outs, to ease lookup within in buildVLocValueMap()
3203 // at time, but avoids re-processing variable values because some other in buildVLocValueMap()
3206 // Re-initialize live-ins and live-outs, to clear the remains of previous in buildVLocValueMap()
3207 // variables live-ins / live-outs. in buildVLocValueMap()
3218 auto &TransferFunc = AllTheVLocs[ExpMBB->getNumber()].Vars; in buildVLocValueMap()
3236 // Insert PHIs into the per-block live-in tables for this variable. in buildVLocValueMap()
3238 unsigned BlockNo = PHIMBB->getNumber(); in buildVLocValueMap()
3250 // * Eliminates un-necessary VPHIs in vlocJoin, in buildVLocValueMap()
3252 // stores the result to the blocks live-outs. in buildVLocValueMap()
3254 // the live-ins change thereafter. in buildVLocValueMap()
3259 CurBB = MBB->getNumber(); in buildVLocValueMap()
3264 DbgValue *LiveIn = LiveInsIt->second; in buildVLocValueMap()
3272 for (const auto *Pred : MBB->predecessors()) in buildVLocValueMap()
3275 // If this block's live-in value is a VPHI, try to pick a machine-value in buildVLocValueMap()
3276 // for it. This makes the machine-value available and propagated in buildVLocValueMap()
3278 // do this any earlier as it needs to read the block live-outs. in buildVLocValueMap()
3279 if (LiveIn->Kind == DbgValue::VPHI && LiveIn->BlockNo == (int)CurBB) { in buildVLocValueMap()
3281 // eliminated and transitions from VPHI-with-location to in buildVLocValueMap()
3282 // live-through-value. As a result, the selected location of any VPHI in buildVLocValueMap()
3283 // might change, so we need to re-compute it on each iteration. in buildVLocValueMap()
3287 bool NewLocPicked = !equal(LiveIn->getDbgOpIDs(), JoinedOps); in buildVLocValueMap()
3290 LiveIn->setDbgOpIDs(JoinedOps); in buildVLocValueMap()
3301 auto &VTracker = AllTheVLocs[MBB->getNumber()]; in buildVLocValueMap()
3305 if (TransferIt->second.Kind == DbgValue::Undef) { in buildVLocValueMap()
3306 DbgValue NewVal(MBB->getNumber(), EmptyProperties, DbgValue::NoVal); in buildVLocValueMap()
3313 if (*LiveOut != TransferIt->second) { in buildVLocValueMap()
3314 *LiveOut = TransferIt->second; in buildVLocValueMap()
3319 // Just copy live-ins to live-outs, for anything not transferred. in buildVLocValueMap()
3326 // If no live-out value changed, there's no need to explore further. in buildVLocValueMap()
3330 // We should visit all successors. Ensure we'll visit any non-backedge in buildVLocValueMap()
3333 for (auto *s : MBB->successors()) { in buildVLocValueMap()
3334 // Ignore out of scope / not-to-be-explored successors. in buildVLocValueMap()
3353 // Save live-ins to output vector. Ignore any that are still marked as being in buildVLocValueMap()
3354 // VPHIs with no location -- those are variables that we know the value of, in buildVLocValueMap()
3358 if (BlockLiveIn->Kind == DbgValue::NoVal) in buildVLocValueMap()
3360 if (BlockLiveIn->isUnjoinedPHI()) in buildVLocValueMap()
3362 if (BlockLiveIn->Kind == DbgValue::VPHI) in buildVLocValueMap()
3363 BlockLiveIn->Kind = DbgValue::Def; in buildVLocValueMap()
3365 assert(BlockLiveIn->Properties.DIExpr->getFragmentInfo() == in buildVLocValueMap()
3368 Output[MBB->getNumber()].push_back(std::make_pair(VarID, *BlockLiveIn)); in buildVLocValueMap()
3370 } // Per-variable loop. in buildVLocValueMap()
3388 // This is a common case, hence it's worth special-casing it. in placePHIsForSingleVarDefinition()
3391 VLocTracker &VLocs = AllTheVLocs[AssignMBB->getNumber()]; in placePHIsForSingleVarDefinition()
3393 const DbgValue &Value = ValueIt->second; in placePHIsForSingleVarDefinition()
3401 // Skip the definition block -- it's assigned the variable value in the middle in placePHIsForSingleVarDefinition()
3404 if (!DomTree->properlyDominates(AssignMBB, ScopeBlock)) in placePHIsForSingleVarDefinition()
3407 Output[ScopeBlock->getNumber()].push_back({VarID, Value}); in placePHIsForSingleVarDefinition()
3410 // All blocks that aren't dominated have no live-in value, thus no variable in placePHIsForSingleVarDefinition()
3418 std::string foo = MTracker->LocIdxToName(P.first); in dump_mloc_transfer()
3419 std::string bar = MTracker->IDAsString(P.second); in dump_mloc_transfer()
3420 dbgs() << "Loc " << foo << " --> " << bar << "\n"; in dump_mloc_transfer()
3431 auto hasNonArtificialLocation = [](const MachineInstr &MI) -> bool { in initialSetup()
3455 BBNumToRPO[MBB->getNumber()] = RPONumber; in initialSetup()
3473 assert(It->Src != std::next(It)->Src && "Duplicate variable location " in initialSetup()
3480 // Produce an "ejection map" for blocks, i.e., what's the highest-numbered
3493 WorkStack.push_back({TopScope, TopScope->getChildren().size() - 1}); in makeDepthFirstEjectionMap()
3498 ssize_t ChildNum = ScopePosition.second--; in makeDepthFirstEjectionMap()
3500 const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren(); in makeDepthFirstEjectionMap()
3503 // Push the child and its children-count onto the stack. in makeDepthFirstEjectionMap()
3506 std::make_pair(ChildScope, ChildScope->getChildren().size() - 1)); in makeDepthFirstEjectionMap()
3515 getBlocksForScope(DILocationIt->second, BlocksToExplore, in makeDepthFirstEjectionMap()
3516 ScopeToAssignBlocks.find(WS)->second); in makeDepthFirstEjectionMap()
3518 unsigned BBNum = MBB->getNumber(); in makeDepthFirstEjectionMap()
3520 EjectionMap[BBNum] = WS->getDFSOut(); in makeDepthFirstEjectionMap()
3537 unsigned NumLocs = MTracker->getNumLocs(); in depthFirstVLocAndEmit()
3550 // Helper lambda for ejecting a block -- if nothing is going to use the block, in depthFirstVLocAndEmit()
3553 auto EjectBlock = [&](MachineBasicBlock &MBB) -> void { in depthFirstVLocAndEmit()
3557 // Prime the transfer-tracker, and then step through all the block in depthFirstVLocAndEmit()
3559 MTracker->reset(); in depthFirstVLocAndEmit()
3560 MTracker->loadFromArray(MInLocs[MBB], BBNum); in depthFirstVLocAndEmit()
3561 TTracker->loadInlocs(MBB, MInLocs[MBB], DbgOpStore, Output[BBNum], NumLocs); in depthFirstVLocAndEmit()
3567 TTracker->checkInstForNewValues(CurInst, MI.getIterator()); in depthFirstVLocAndEmit()
3571 // Free machine-location tables for this block. in depthFirstVLocAndEmit()
3574 // We don't need live-in variable values for this block either. in depthFirstVLocAndEmit()
3593 // have a DILocation -- by proxy, this means we never tracked any variable in depthFirstVLocAndEmit()
3596 if (HighestDFSIn <= WS->getDFSIn() && DILocIt != ScopeToDILocation.end()) { in depthFirstVLocAndEmit()
3597 const DILocation *DILoc = DILocIt->second; in depthFirstVLocAndEmit()
3598 auto &VarsWeCareAbout = ScopeToVars.find(WS)->second; in depthFirstVLocAndEmit()
3599 auto &BlocksInScope = ScopeToAssignBlocks.find(WS)->second; in depthFirstVLocAndEmit()
3605 HighestDFSIn = std::max(HighestDFSIn, WS->getDFSIn()); in depthFirstVLocAndEmit()
3608 const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren(); in depthFirstVLocAndEmit()
3610 // There are children to explore -- push onto stack and continue. in depthFirstVLocAndEmit()
3622 getBlocksForScope(DILocationIt->second, BlocksToExplore, in depthFirstVLocAndEmit()
3623 ScopeToAssignBlocks.find(WS)->second); in depthFirstVLocAndEmit()
3625 if (WS->getDFSOut() == EjectionMap[MBB->getNumber()]) in depthFirstVLocAndEmit()
3635 // anything for such out-of-scope blocks, but for the sake of being similar in depthFirstVLocAndEmit()
3645 // Go through all the transfers recorded in the TransferTracker -- this is in emitTransfers()
3646 // both the live-ins to a block, and any movements of values that happen in emitTransfers()
3648 for (auto &P : TTracker->Transfers) { in emitTransfers()
3663 if (P.Pos->isTerminator()) in emitTransfers()
3666 MachineBasicBlock &MBB = *P.Pos->getParent(); in emitTransfers()
3672 return TTracker->Transfers.size() != 0; in emitTransfers()
3687 this->TPC = TPC; in ExtendRanges()
3689 this->DomTree = DomTree; in ExtendRanges()
3694 TFI->getCalleeSaves(MF, CalleeSavedRegs); in ExtendRanges()
3699 AdjustsStackInCalls = MFI->adjustsStack() && in ExtendRanges()
3700 STI.getFrameLowering()->stackProbeFunctionModifiesSP(); in ExtendRanges()
3702 StackProbeSymbolName = STI.getTargetLowering()->getStackProbeSymbolName(MF); in ExtendRanges()
3713 int MaxNumBlocks = -1; in ExtendRanges()
3727 // Allocate and initialize two array-of-arrays for the live-in and live-out in ExtendRanges()
3730 unsigned NumLocs = MTracker->getNumLocs(); in ExtendRanges()
3735 // storing the computed live-ins / live-outs into the array-of-arrays. We use in ExtendRanges()
3736 // both live-ins and live-outs for decision making in the variable value in ExtendRanges()
3740 // Patch up debug phi numbers, turning unknown block-live-in values into in ExtendRanges()
3741 // either live-through machine values, or PHIs. in ExtendRanges()
3743 // Identify unresolved block-live-ins. in ExtendRanges()
3754 // If there is no resolved value for this live-in then it is not directly in ExtendRanges()
3755 // reachable from the entry block -- model it as a PHI on entry to this in ExtendRanges()
3766 CurBB = MBB->getNumber(); in ExtendRanges()
3768 VTracker->MBB = MBB; in ExtendRanges()
3769 MTracker->loadFromArray(MInLocs[*MBB], CurBB); in ExtendRanges()
3775 MTracker->reset(); in ExtendRanges()
3793 auto *VTracker = &vlocs[MBB->getNumber()]; in ExtendRanges()
3795 for (auto &idx : VTracker->Vars) { in ExtendRanges()
3797 const DILocation *ScopeLoc = VTracker->Scopes[VarID]; in ExtendRanges()
3801 // No insts in scope -> shouldn't have been recorded. in ExtendRanges()
3805 ScopeToAssignBlocks[Scope].insert(VTracker->MBB); in ExtendRanges()
3824 // a lexical-scope-depth search. It should be functionally identical to in ExtendRanges()
3862 // expects to zero-initialize the type.
3941 /// Map of which blocks generate Undef values -- blocks that are not
3948 /// Table of live-in machine value numbers for blocks / locations.
3973 return it->second; in getSSALDVBlock()
3976 /// Find the live-in value number for the given block. Looks up the value at
3979 return MLiveIns[LDVBB->BB][Loc.asU64()].asU64(); in getValue()
4011 // Methods to access block successors -- dereferencing to our wrapper class.
4012 static BlkSucc_iterator BlkSucc_begin(BlkT *BB) { return BB->succ_begin(); } in BlkSucc_begin()
4013 static BlkSucc_iterator BlkSucc_end(BlkT *BB) { return BB->succ_end(); } in BlkSucc_end()
4025 : PHI(P), Idx(PHI->IncomingValues.size()) {} in PHI_iterator()
4034 BlockValueNum getIncomingValue() { return PHI->IncomingValues[Idx].second; } in getIncomingValue()
4036 LDVSSABlock *getIncomingBlock() { return PHI->IncomingValues[Idx].first; } in getIncomingBlock()
4045 /// FindPredecessorBlocks - Put the predecessors of BB into the Preds
4049 for (MachineBasicBlock *Pred : BB->BB.predecessors()) in FindPredecessorBlocks()
4050 Preds->push_back(BB->Updater.getSSALDVBlock(Pred)); in FindPredecessorBlocks()
4053 /// GetPoisonVal - Normally creates an IMPLICIT_DEF instruction with a new
4057 // Create a value number for this block -- it needs to be unique and in the in GetPoisonVal()
4060 BlockValueNum Num = ValueIDNum(BB->BB.getNumber(), 0, Updater->Loc).asU64(); in GetPoisonVal()
4061 Updater->PoisonMap[&BB->BB] = Num; in GetPoisonVal()
4065 /// CreateEmptyPHI - Create a (representation of a) PHI in the given block.
4068 /// solution determined it to be. This includes non-phi values if SSAUpdater
4072 BlockValueNum PHIValNum = Updater->getValue(BB); in CreateEmptyPHI()
4073 LDVSSAPhi *PHI = BB->newPHI(PHIValNum); in CreateEmptyPHI()
4074 Updater->PHIs[PHIValNum] = PHI; in CreateEmptyPHI()
4078 /// AddPHIOperand - Add the specified value as an operand of the PHI for
4081 PHI->IncomingValues.push_back(std::make_pair(Pred, Val)); in AddPHIOperand()
4084 /// ValueIsPHI - Check if the instruction that defines the specified value
4087 return Updater->PHIs.lookup(Val); in ValueIsPHI()
4090 /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source
4094 if (PHI && PHI->IncomingValues.size() == 0) in ValueIsNewPHI()
4099 /// GetPHIValue - For the specified PHI instruction, return the value
4101 static BlockValueNum GetPHIValue(LDVSSAPhi *PHI) { return PHI->PHIValNum; } in GetPHIValue()
4113 return SeenDbgPHIIt->second; in resolveDbgPHIs()
4146 return *LowerIt->ValueRead; in resolveDbgPHIsImpl()
4152 LocIdx Loc = *LowerIt->ReadLoc; in resolveDbgPHIsImpl()
4157 // value, just like SSA. We use the bulk-standard LLVM SSA updater class to in resolveDbgPHIsImpl()
4178 // Actually, we already know what the value is -- the Use is in the same in resolveDbgPHIsImpl()
4180 return ValueIDNum::fromU64(AvailIt->second); in resolveDbgPHIsImpl()
4189 // We have the number for a PHI, or possibly live-through value, to be used in resolveDbgPHIsImpl()
4197 // predecessor values the same, leading to a non-PHI machine value number? in resolveDbgPHIsImpl()
4209 // Sort PHIs to validate into RPO-order. in resolveDbgPHIsImpl()
4215 return BBToOrder[&A->getParent()->BB] < BBToOrder[&B->getParent()->BB]; in resolveDbgPHIsImpl()
4219 ValueIDNum ThisBlockValueNum = MLiveIns[PHI->ParentBlock->BB][Loc.asU64()]; in resolveDbgPHIsImpl()
4222 for (auto &PHIIt : PHI->IncomingValues) { in resolveDbgPHIsImpl()
4224 if (Updater.PoisonMap.contains(&PHIIt.first->BB)) in resolveDbgPHIsImpl()
4228 const ValueTable &BlockLiveOuts = MLiveOuts[PHIIt.first->BB]; in resolveDbgPHIsImpl()
4234 // migrate into loops -- meaning we can only be live-through this in resolveDbgPHIsImpl()
4238 // Does the block have as a live-out, in the location we're examining, in resolveDbgPHIsImpl()
4240 ValueToCheck = VVal->second; in resolveDbgPHIsImpl()
4248 ValidatedValues.insert({PHI->ParentBlock, ThisBlockValueNum}); in resolveDbgPHIsImpl()