aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp25
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);
}
}