Lines Matching defs:VarLoc

1 //===- VarLocBasedImpl.cpp - Tracking Debug Value MIs with VarLoc class----===//
24 /// locations, using the VarLoc class.
80 /// VarLoc object that identifies the source variable, the set of
83 /// specifies the location. Each VarLoc is indexed in the (function-scope) \p
84 /// VarLocMap, giving each VarLoc a set of unique indexes, each of which
85 /// corresponds to one of the VarLoc's machine-locations and can be used to
86 /// lookup the VarLoc in the VarLocMap. Rather than operate directly on machine
108 /// a new VarLoc is created with its bit not set in predecessor InLocs or
189 // that represent Entry Values; every VarLoc in the set will also appear
191 // As a result, each VarLoc may appear more than once in this "set", but each
193 // "true" set (i.e. each VarLoc may appear only once), and the range Location=0
214 /// The location that has an entry for every VarLoc in the map.
272 // Simple Set for storing all the VarLoc Indices at a Location bucket.
274 // Vector of all `LocIndex`s for a given VarLoc; the same Location should not
275 // appear in any two of these, as each VarLoc appears at most once in any
297 struct VarLoc {
366 /// If the VarLoc is not a NonEntryValueKind, then it will use only a
422 VarLoc(const MachineInstr &MI)
475 static VarLoc CreateEntryLoc(const MachineInstr &MI,
477 VarLoc VL(MI);
490 static VarLoc CreateEntryBackupLoc(const MachineInstr &MI,
492 VarLoc VL(MI);
503 static VarLoc CreateEntryCopyBackupLoc(const MachineInstr &MI,
506 VarLoc VL(MI);
517 static VarLoc CreateCopyLoc(const VarLoc &OldVL, const MachineLoc &OldML,
519 VarLoc VL = OldVL;
526 llvm_unreachable("Should have found OldML in new VarLoc.");
529 /// Take the variable described by DBG_VALUE* MI, and create a VarLoc
531 static VarLoc CreateSpillLoc(const VarLoc &OldVL, const MachineLoc &OldML,
533 VarLoc VL = OldVL;
540 llvm_unreachable("Should have found OldML in new VarLoc.");
543 /// Create a DBG_VALUE representing this VarLoc in the given function.
549 "Tried to produce DBG_VALUE for backup VarLoc");
569 // DBG_VALUE, but with the register number from this VarLoc.
606 llvm_unreachable("Tried to produce DBG_VALUE for invalid VarLoc");
666 return any_of(Locs, [](VarLoc::MachineLoc ML) {
667 return ML.Kind == VarLoc::MachineLocKind::SpillLocKind;
691 return any_of(Locs, [](VarLoc::MachineLoc ML) {
692 return ML.Kind == VarLoc::MachineLocKind::WasmLocKind;
715 Out << "VarLoc(";
750 llvm_unreachable("Invalid VarLoc in dump method");
767 bool operator==(const VarLoc &Other) const {
773 bool operator<(const VarLoc &Other) const {
780 using VarVec = SmallVector<VarLoc, 32>;
784 /// 1) Assigning LocIndices to a VarLoc. The LocIndices can be used to
785 /// virtually insert a VarLoc into a VarLocSet.
786 /// 2) Given a LocIndex, look up the unique associated VarLoc.
788 /// Map a VarLoc to an index within the vector reserved for its location
790 std::map<VarLoc, LocIndices> Var2Indices;
794 SmallDenseMap<LocIndex::u32_location_t, std::vector<VarLoc>> Loc2Vars;
798 LocIndices insert(const VarLoc &VL) {
809 if (VL.EVKind == VarLoc::EntryValueLocKind::NonEntryValueKind) {
820 } else if (VL.EVKind != VarLoc::EntryValueLocKind::EntryValueKind) {
834 LocIndices getAllIndices(const VarLoc &VL) const {
836 assert(IndIt != Var2Indices.end() && "VarLoc not tracked");
840 /// Retrieve the unique VarLoc associated with \p ID.
841 const VarLoc &operator[](LocIndex ID) const {
873 /// Collects all VarLocs from \p CollectFrom. Each unique VarLoc is added
875 static void collectAllVarLocs(SmallVectorImpl<VarLoc> &Collected,
889 /// methods act differently depending on whether a VarLoc is primary
890 /// location or backup one. In the case the VarLoc is backup location
909 // This method is needed to get every VarLoc once, as each VarLoc may have
913 void getUniqueVarLocs(SmallVectorImpl<VarLoc> &Collected,
919 void erase(const VarLoc &VL);
927 void insert(LocIndices VarLocIDs, const VarLoc &VL);
949 /// Get an empty range of VarLoc IDs.
980 /// Collect all VarLoc IDs from \p CollectFrom for VarLocs with MLs of kind
982 /// VarLoc correspond to entries in the universal location bucket, which every
983 /// VarLoc has exactly 1 entry for. Insert collected IDs into \p Collected.
1025 std::optional<VarLoc::SpillLoc> isRestoreInstruction(const MachineInstr &MI,
1030 VarLoc::SpillLoc extractSpillBaseRegAndOffset(const MachineInstr &MI);
1034 const VarLoc::MachineLoc &OldLoc,
1045 VarLocMap &VarLocIDs, const VarLoc &EntryVL,
1048 VarLocMap &VarLocIDs, const VarLoc &EntryVL,
1113 /// fragments that may overlap it. If the VarLoc is a backup location, erase
1115 /// tracking its backup entry location. Otherwise, if the VarLoc is primary
1117 void VarLocBasedLDV::OpenRangesSet::erase(const VarLoc &VL) {
1157 const VarLoc &VL = VarLocIDs[LocIndex(Location, ID)];
1175 const VarLoc &VarL = Map[Idx];
1182 const VarLoc &VL) {
1212 // all possible VarLoc IDs for VarLocs with MLs of kind RegisterKind which
1221 const VarLoc &VL = VarLocIDs[ItIdx];
1225 "Unexpected order of LocIndices for VarLoc; was it inserted into "
1246 // We found a VarLoc ID for a VarLoc that lives in a register. Figure out
1278 SmallVector<VarLoc, 32> VarLocs;
1281 for (const VarLoc &VL : VarLocs) {
1291 VarLocBasedLDV::VarLoc::SpillLoc
1310 const VarLoc &EntryVL, InstToEntryLocMap &EntryValTransfers) {
1316 const VarLoc &EmittedEV = VarLocIDs[TDPair.second];
1334 const VarLoc &EntryVL,
1374 const VarLoc &VL = VarLocIDs[LocIndex::fromRawInteger(ID)];
1415 const VarLoc &EntryVL = VarLocIDs[EntryValBackupID->back()];
1424 // Use normal VarLoc constructor for registers and immediates.
1425 VarLoc VL(MI);
1430 // Add the VarLoc to OpenRanges from this DBG_VALUE.
1438 VarLoc VL(MI);
1444 void VarLocBasedLDV::collectAllVarLocs(SmallVectorImpl<VarLoc> &Collected,
1448 // possible VarLoc IDs for VarLocs with MLs of kind RegisterKind which live
1474 const VarLoc &VL = VarLocIDs[Idx];
1487 const VarLoc &EntryVL = VarLocIDs[EntryValBackupIDs->back()];
1488 VarLoc EntryLoc = VarLoc::CreateEntryLoc(EntryVL.MI, EntryVL.Expr,
1498 /// Create new TransferDebugPair and insert it in \p Transfers. The VarLoc
1500 /// new VarLoc. If \p NewReg is different than default zero value then the
1506 const VarLoc::MachineLoc &OldLoc, Register NewReg) {
1507 const VarLoc &OldVarLoc = VarLocIDs[OldVarID];
1509 auto ProcessVarLoc = [&MI, &OpenRanges, &Transfers, &VarLocIDs](VarLoc &VL) {
1531 VarLoc VL = VarLoc::CreateCopyLoc(OldVarLoc, OldLoc, NewReg);
1534 dbgs() << "Creating VarLoc for register copy:";
1542 VarLoc::SpillLoc SpillLocation = extractSpillBaseRegAndOffset(MI);
1543 VarLoc VL = VarLoc::CreateSpillLoc(
1547 dbgs() << "Creating VarLoc for spill:";
1557 VarLoc VL = VarLoc::CreateCopyLoc(OldVarLoc, OldLoc, NewReg);
1560 dbgs() << "Creating VarLoc for restore:";
1658 VarLoc::WasmLoc Loc{Index, Offset};
1661 const VarLoc &VL = VarLocIDs[Idx];
1722 std::optional<VarLocBasedLDV::VarLoc::SpillLoc>
1751 std::optional<VarLoc::SpillLoc> Loc;
1763 const VarLoc &VL = VarLocIDs[Idx];
1778 VarLoc::MachineLoc OldLoc = VL.Locs[SpillLocIdx];
1779 VarLoc UndefVL = VarLoc::CreateCopyLoc(VL, OldLoc, 0);
1810 const VarLoc &VL = VarLocIDs[Idx];
1827 VarLoc::MachineLoc MLoc = VL.Locs[LocIdx];
1877 const VarLoc &VL = VarLocIDs[Idx];
1880 VarLoc EntryValLocCopyBackup =
1881 VarLoc::CreateEntryCopyBackupLoc(VL.MI, VL.Expr, DestReg);
1899 VarLoc::MachineLocValue Loc;
1901 VarLoc::MachineLoc MLoc{VarLoc::MachineLocKind::RegisterKind, Loc};
1919 for (VarLoc &VL : VarLocs) {
2055 for (const VarLoc &VL : VarLocs)
2106 SmallVector<VarLoc, 32> VarLocs;
2109 for (VarLoc DiffIt : VarLocs) {
2200 VarLoc EntryValLocAsBackup = VarLoc::CreateEntryBackupLoc(MI, NewExpr);
2234 VarLocMap VarLocIDs; // Map VarLoc<>unique ID for use in bitvectors.
2374 const VarLoc &VL = VarLocIDs[TR.LocationID];
2386 const VarLoc &VL = VarLocIDs[TR.second];