Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
}

bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
// Except for Wasm, all targets should be only using physical register at this
// point. Wasm only use virtual registers throught its pipeline, but its
// virtual registers don't participate in this LiveDebugValues analysis; only
// its target indices do.
assert(MF.getTarget().getTargetTriple().isWasm() ||
MF.getProperties().hasProperty(
MachineFunctionProperties::Property::NoVRegs));

bool InstrRefBased = MF.useDebugInstrRef();
// Allow the user to force selection of InstrRef LDV.
InstrRefBased |= ForceInstrRefLDV;
Expand Down
19 changes: 15 additions & 4 deletions llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down Expand Up @@ -810,9 +814,10 @@ class VarLocBasedLDV : public LDVImpl {
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())
Expand Down Expand Up @@ -1240,9 +1245,15 @@ void VarLocBasedLDV::getUsedRegs(const VarLocSet &CollectFrom,
LocIndex::rawIndexForReg(LocIndex::kFirstRegLocation);
uint64_t FirstInvalidIndex =
LocIndex::rawIndexForReg(LocIndex::kFirstInvalidRegLocation);
uint64_t FirstVirtualRegIndex =
LocIndex::rawIndexForReg(LocIndex::kFirstVirtualRegLocation);
for (auto It = CollectFrom.find(FirstRegIndex),
End = CollectFrom.find(FirstInvalidIndex);
It != End;) {
PhysEnd = CollectFrom.find(FirstInvalidIndex);
It != CollectFrom.end();) {
if (It == PhysEnd) {
It = CollectFrom.find(FirstVirtualRegIndex);
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving the code within the for loop into a lambda, and then having two different for loops invoke the lambda internally? The first loop would go over physical registers, and the second one would go over virtual ones. I think the code would be clearer that way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, I had it written that way, then decided that this was better.

// 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;
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ void NVPTXPassConfig::addIRPasses() {
disablePass(&MachineCopyPropagationID);
disablePass(&TailDuplicateID);
disablePass(&StackMapLivenessID);
disablePass(&LiveDebugValuesID);
disablePass(&PostRAMachineSinkingID);
disablePass(&PostRASchedulerID);
disablePass(&FuncletLayoutID);
Expand Down
Loading
Loading