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
188 // that represent Entry Values; every VarLoc in the set will also appear
190 // As a result, each VarLoc may appear more than once in this "set", but each
192 // "true" set (i.e. each VarLoc may appear only once), and the range Location=0
213 /// The location that has an entry for every VarLoc in the map.
275 // Simple Set for storing all the VarLoc Indices at a Location bucket.
277 // Vector of all `LocIndex`s for a given VarLoc; the same Location should not
278 // appear in any two of these, as each VarLoc appears at most once in any
300 struct VarLoc {
369 /// If the VarLoc is not a NonEntryValueKind, then it will use only a
425 VarLoc(const MachineInstr &MI)
478 static VarLoc CreateEntryLoc(const MachineInstr &MI,
480 VarLoc VL(MI);
493 static VarLoc CreateEntryBackupLoc(const MachineInstr &MI,
495 VarLoc VL(MI);
506 static VarLoc CreateEntryCopyBackupLoc(const MachineInstr &MI,
509 VarLoc VL(MI);
520 static VarLoc CreateCopyLoc(const VarLoc &OldVL, const MachineLoc &OldML,
522 VarLoc VL = OldVL;
529 llvm_unreachable("Should have found OldML in new VarLoc.");
532 /// Take the variable described by DBG_VALUE* MI, and create a VarLoc
534 static VarLoc CreateSpillLoc(const VarLoc &OldVL, const MachineLoc &OldML,
536 VarLoc VL = OldVL;
543 llvm_unreachable("Should have found OldML in new VarLoc.");
546 /// Create a DBG_VALUE representing this VarLoc in the given function.
552 "Tried to produce DBG_VALUE for backup VarLoc");
572 // DBG_VALUE, but with the register number from this VarLoc.
609 llvm_unreachable("Tried to produce DBG_VALUE for invalid VarLoc");
669 return any_of(Locs, [](VarLoc::MachineLoc ML) {
670 return ML.Kind == VarLoc::MachineLocKind::SpillLocKind;
694 return any_of(Locs, [](VarLoc::MachineLoc ML) {
695 return ML.Kind == VarLoc::MachineLocKind::WasmLocKind;
718 Out << "VarLoc(";
753 llvm_unreachable("Invalid VarLoc in dump method");
770 bool operator==(const VarLoc &Other) const {
776 bool operator<(const VarLoc &Other) const {
783 using VarVec = SmallVector<VarLoc, 32>;
787 /// 1) Assigning LocIndices to a VarLoc. The LocIndices can be used to
788 /// virtually insert a VarLoc into a VarLocSet.
789 /// 2) Given a LocIndex, look up the unique associated VarLoc.
791 /// Map a VarLoc to an index within the vector reserved for its location
793 std::map<VarLoc, LocIndices> Var2Indices;
797 SmallDenseMap<LocIndex::u32_location_t, std::vector<VarLoc>> Loc2Vars;
801 LocIndices insert(const VarLoc &VL) {
812 if (VL.EVKind == VarLoc::EntryValueLocKind::NonEntryValueKind) {
824 } else if (VL.EVKind != VarLoc::EntryValueLocKind::EntryValueKind) {
838 LocIndices getAllIndices(const VarLoc &VL) const {
840 assert(IndIt != Var2Indices.end() && "VarLoc not tracked");
844 /// Retrieve the unique VarLoc associated with \p ID.
845 const VarLoc &operator[](LocIndex ID) const {
877 /// Collects all VarLocs from \p CollectFrom. Each unique VarLoc is added
879 static void collectAllVarLocs(SmallVectorImpl<VarLoc> &Collected,
893 /// methods act differently depending on whether a VarLoc is primary
894 /// location or backup one. In the case the VarLoc is backup location
913 // This method is needed to get every VarLoc once, as each VarLoc may have
917 void getUniqueVarLocs(SmallVectorImpl<VarLoc> &Collected,
923 void erase(const VarLoc &VL);
931 void insert(LocIndices VarLocIDs, const VarLoc &VL);
953 /// Get an empty range of VarLoc IDs.
984 /// Collect all VarLoc IDs from \p CollectFrom for VarLocs with MLs of kind
986 /// VarLoc correspond to entries in the universal location bucket, which every
987 /// VarLoc has exactly 1 entry for. Insert collected IDs into \p Collected.
1029 std::optional<VarLoc::SpillLoc> isRestoreInstruction(const MachineInstr &MI,
1034 VarLoc::SpillLoc extractSpillBaseRegAndOffset(const MachineInstr &MI);
1038 const VarLoc::MachineLoc &OldLoc,
1049 VarLocMap &VarLocIDs, const VarLoc &EntryVL,
1052 VarLocMap &VarLocIDs, const VarLoc &EntryVL,
1117 /// fragments that may overlap it. If the VarLoc is a backup location, erase
1119 /// tracking its backup entry location. Otherwise, if the VarLoc is primary
1121 void VarLocBasedLDV::OpenRangesSet::erase(const VarLoc &VL) {
1161 const VarLoc &VL = VarLocIDs[LocIndex(Location, ID)];
1179 const VarLoc &VarL = Map[Idx];
1186 const VarLoc &VL) {
1216 // all possible VarLoc IDs for VarLocs with MLs of kind RegisterKind which
1225 const VarLoc &VL = VarLocIDs[ItIdx];
1229 "Unexpected order of LocIndices for VarLoc; was it inserted into "
1250 // We found a VarLoc ID for a VarLoc that lives in a register. Figure out
1292 SmallVector<VarLoc, 32> VarLocs;
1295 for (const VarLoc &VL : VarLocs) {
1305 VarLocBasedLDV::VarLoc::SpillLoc
1324 const VarLoc &EntryVL, InstToEntryLocMap &EntryValTransfers) {
1330 const VarLoc &EmittedEV = VarLocIDs[TDPair.second];
1348 const VarLoc &EntryVL,
1388 const VarLoc &VL = VarLocIDs[LocIndex::fromRawInteger(ID)];
1429 const VarLoc &EntryVL = VarLocIDs[EntryValBackupID->back()];
1438 // Use normal VarLoc constructor for registers and immediates.
1439 VarLoc VL(MI);
1444 // Add the VarLoc to OpenRanges from this DBG_VALUE.
1452 VarLoc VL(MI);
1458 void VarLocBasedLDV::collectAllVarLocs(SmallVectorImpl<VarLoc> &Collected,
1462 // possible VarLoc IDs for VarLocs with MLs of kind RegisterKind which live
1488 const VarLoc &VL = VarLocIDs[Idx];
1501 const VarLoc &EntryVL = VarLocIDs[EntryValBackupIDs->back()];
1502 VarLoc EntryLoc = VarLoc::CreateEntryLoc(EntryVL.MI, EntryVL.Expr,
1512 /// Create new TransferDebugPair and insert it in \p Transfers. The VarLoc
1514 /// new VarLoc. If \p NewReg is different than default zero value then the
1520 const VarLoc::MachineLoc &OldLoc, Register NewReg) {
1521 const VarLoc &OldVarLoc = VarLocIDs[OldVarID];
1523 auto ProcessVarLoc = [&MI, &OpenRanges, &Transfers, &VarLocIDs](VarLoc &VL) {
1545 VarLoc VL = VarLoc::CreateCopyLoc(OldVarLoc, OldLoc, NewReg);
1548 dbgs() << "Creating VarLoc for register copy:";
1556 VarLoc::SpillLoc SpillLocation = extractSpillBaseRegAndOffset(MI);
1557 VarLoc VL = VarLoc::CreateSpillLoc(
1561 dbgs() << "Creating VarLoc for spill:";
1571 VarLoc VL = VarLoc::CreateCopyLoc(OldVarLoc, OldLoc, NewReg);
1574 dbgs() << "Creating VarLoc for restore:";
1672 VarLoc::WasmLoc Loc{Index, Offset};
1675 const VarLoc &VL = VarLocIDs[Idx];
1736 std::optional<VarLocBasedLDV::VarLoc::SpillLoc>
1765 std::optional<VarLoc::SpillLoc> Loc;
1777 const VarLoc &VL = VarLocIDs[Idx];
1792 VarLoc::MachineLoc OldLoc = VL.Locs[SpillLocIdx];
1793 VarLoc UndefVL = VarLoc::CreateCopyLoc(VL, OldLoc, 0);
1824 const VarLoc &VL = VarLocIDs[Idx];
1841 VarLoc::MachineLoc MLoc = VL.Locs[LocIdx];
1891 const VarLoc &VL = VarLocIDs[Idx];
1894 VarLoc EntryValLocCopyBackup =
1895 VarLoc::CreateEntryCopyBackupLoc(VL.MI, VL.Expr, DestReg);
1913 VarLoc::MachineLocValue Loc;
1915 VarLoc::MachineLoc MLoc{VarLoc::MachineLocKind::RegisterKind, Loc};
1933 for (VarLoc &VL : VarLocs) {
2067 for (const VarLoc &VL : VarLocs)
2118 SmallVector<VarLoc, 32> VarLocs;
2121 for (VarLoc DiffIt : VarLocs) {
2212 VarLoc EntryValLocAsBackup = VarLoc::CreateEntryBackupLoc(MI, NewExpr);
2246 VarLocMap VarLocIDs; // Map VarLoc<>unique ID for use in bitvectors.
2386 const VarLoc &VL = VarLocIDs[TR.LocationID];
2398 const VarLoc &VL = VarLocIDs[TR.second];