Skip to content

Commit 3e52d24

Browse files
committed
add a debug dump function for ValueLifetimeAnalysis
1 parent c01e8ed commit 3e52d24

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/swift/SILOptimizer/Utils/Local.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ class ValueLifetimeAnalysis {
270270
/// It is assumed that \p Inst is located after the value's definition.
271271
bool isWithinLifetime(SILInstruction *Inst);
272272

273+
/// For debug dumping.
274+
void dump() const;
275+
273276
private:
274277

275278
/// The value.

lib/SILOptimizer/Utils/Local.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,18 @@ bool ValueLifetimeAnalysis::isWithinLifetime(SILInstruction *Inst) {
12401240
llvm_unreachable("Expected to find use of value in block!");
12411241
}
12421242

1243+
void ValueLifetimeAnalysis::dump() const {
1244+
llvm::errs() << "lifetime of def: " << *DefValue;
1245+
for (SILInstruction *Use : UserSet) {
1246+
llvm::errs() << " use: " << *Use;
1247+
}
1248+
llvm::errs() << " live blocks:";
1249+
for (SILBasicBlock *BB : LiveBlocks) {
1250+
llvm::errs() << ' ' << BB->getDebugID();
1251+
}
1252+
llvm::errs() << '\n';
1253+
}
1254+
12431255
//===----------------------------------------------------------------------===//
12441256
// Casts Optimization and Simplification
12451257
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)