diff options
author | William G Hatch <william@hatch.uno> | 2024-10-08 19:38:47 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 19:38:47 -0600 |
commit | 181840459d2c8841ab8a564d4fbac6efc65e0fa9 (patch) | |
tree | bd01b75927f65a5c9eaac4f2f1b8beefb44a68f6 /llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp | |
parent | ff6facaa61d9bd58ec375be80fc725b2bb6fbadf (diff) | |
download | llvm-181840459d2c8841ab8a564d4fbac6efc65e0fa9.zip llvm-181840459d2c8841ab8a564d4fbac6efc65e0fa9.tar.gz llvm-181840459d2c8841ab8a564d4fbac6efc65e0fa9.tar.bz2 |
[LiveDebugValues][NVPTX]VarLocBasedImpl handle vregs, enable for NVPTX (#111456)
This patch handles virtual registers in the VarLocBasedImpl of the
LiveDebugVariables pass, allowing it to be used on architectures that
depend on virtual registers in debugging, like NVPTX. It enables the
pass for NVPTX.
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp index 7e7d90f..c80b54a 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp @@ -239,6 +239,10 @@ struct LocIndex { /// becomes a problem. static constexpr u32_location_t kWasmLocation = kFirstInvalidRegLocation + 2; + /// The first location that is reserved for VarLocs with locations of kind + /// VirtualRegisterKind. + static constexpr u32_location_t kFirstVirtualRegLocation = 1 << 31; + LocIndex(u32_location_t Location, u32_index_t Index) : Location(Location), Index(Index) {} @@ -810,9 +814,10 @@ private: VL.getDescribingRegs(Locations); assert(all_of(Locations, [](auto RegNo) { - return RegNo < LocIndex::kFirstInvalidRegLocation; + return (RegNo < LocIndex::kFirstInvalidRegLocation) || + (LocIndex::kFirstVirtualRegLocation <= RegNo); }) && - "Physreg out of range?"); + "Physical or virtual register out of range?"); if (VL.containsSpillLocs()) Locations.push_back(LocIndex::kSpillLocation); if (VL.containsWasmLocs()) @@ -1240,9 +1245,9 @@ void VarLocBasedLDV::getUsedRegs(const VarLocSet &CollectFrom, LocIndex::rawIndexForReg(LocIndex::kFirstRegLocation); uint64_t FirstInvalidIndex = LocIndex::rawIndexForReg(LocIndex::kFirstInvalidRegLocation); - for (auto It = CollectFrom.find(FirstRegIndex), - End = CollectFrom.find(FirstInvalidIndex); - It != End;) { + uint64_t FirstVirtualRegIndex = + LocIndex::rawIndexForReg(LocIndex::kFirstVirtualRegLocation); + auto doGetUsedRegs = [&](VarLocSet::const_iterator &It) { // We found a VarLoc ID for a VarLoc that lives in a register. Figure out // which register and add it to UsedRegs. uint32_t FoundReg = LocIndex::fromRawInteger(*It).Location; @@ -1255,6 +1260,16 @@ void VarLocBasedLDV::getUsedRegs(const VarLocSet &CollectFrom, // guaranteed to move on to the next register (or to end()). uint64_t NextRegIndex = LocIndex::rawIndexForReg(FoundReg + 1); It.advanceToLowerBound(NextRegIndex); + }; + for (auto It = CollectFrom.find(FirstRegIndex), + End = CollectFrom.find(FirstInvalidIndex); + It != End;) { + doGetUsedRegs(It); + } + for (auto It = CollectFrom.find(FirstVirtualRegIndex), + End = CollectFrom.end(); + It != End;) { + doGetUsedRegs(It); } } |