Skip to content

Commit 17295f6

Browse files
committed
[LiveDebugVariables] Add basic verification
Add a basic implementation of verifyAnalysis that just checks that the analysis does not refer to any SlotIndexes for instructions that have been deleted. This was useful for diagnosing some SlotIndexes-related problems caused by llvm#67038.
1 parent 8e8edda commit 17295f6

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

llvm/lib/CodeGen/LiveDebugVariables.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ class UserValue {
492492
/// Return DebugLoc of this UserValue.
493493
const DebugLoc &getDebugLoc() { return dl; }
494494

495+
void verify() const {
496+
for (auto I = locInts.begin(), E = locInts.end(); I != E; ++I) {
497+
assert(!I.start().isPoisoned());
498+
assert(!I.stop().isPoisoned());
499+
}
500+
}
501+
495502
void print(raw_ostream &, const TargetRegisterInfo *);
496503
};
497504

@@ -655,6 +662,11 @@ class LDVImpl {
655662
ModifiedMF = false;
656663
}
657664

665+
void verify() const {
666+
for (auto [DV, UV] : userVarMap)
667+
UV->verify();
668+
}
669+
658670
/// Map virtual register to an equivalence class.
659671
void mapVirtReg(Register VirtReg, UserValue *EC);
660672

@@ -1320,6 +1332,11 @@ void LiveDebugVariables::releaseMemory() {
13201332
static_cast<LDVImpl*>(pImpl)->clear();
13211333
}
13221334

1335+
void LiveDebugVariables::verifyAnalysis() const {
1336+
if (pImpl)
1337+
static_cast<LDVImpl *>(pImpl)->verify();
1338+
}
1339+
13231340
LiveDebugVariables::~LiveDebugVariables() {
13241341
if (pImpl)
13251342
delete static_cast<LDVImpl*>(pImpl);

llvm/lib/CodeGen/LiveDebugVariables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
5656
bool runOnMachineFunction(MachineFunction &) override;
5757
void releaseMemory() override;
5858
void getAnalysisUsage(AnalysisUsage &) const override;
59+
void verifyAnalysis() const override;
5960

6061
MachineFunctionProperties getSetProperties() const override {
6162
return MachineFunctionProperties().set(

0 commit comments

Comments
 (0)