Skip to content

Commit a0d41c4

Browse files
committed
[MLIR] Adopt LDBG() macro debugging in SymbolDCE.cpp (NFC)
1 parent 7cb2ace commit a0d41c4

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

mlir/lib/Transforms/SymbolDCE.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
#include "mlir/Transforms/Passes.h"
1515

16+
#include "mlir/IR/Operation.h"
1617
#include "mlir/IR/SymbolTable.h"
1718
#include "llvm/Support/Debug.h"
19+
#include "llvm/Support/DebugLog.h"
20+
#include "llvm/Support/InterleavedRange.h"
1821

1922
namespace mlir {
2023
#define GEN_PASS_DEF_SYMBOLDCE
@@ -87,8 +90,8 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp,
8790
SymbolTableCollection &symbolTable,
8891
bool symbolTableIsHidden,
8992
DenseSet<Operation *> &liveSymbols) {
90-
LLVM_DEBUG(llvm::dbgs() << "computeLiveness: " << symbolTableOp->getName()
91-
<< "\n");
93+
LDBG() << "computeLiveness: "
94+
<< OpWithFlags(symbolTableOp, OpPrintingFlags().skipRegions());
9295
// A worklist of live operations to propagate uses from.
9396
SmallVector<Operation *, 16> worklist;
9497

@@ -116,21 +119,23 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp,
116119
// consideration.
117120
while (!worklist.empty()) {
118121
Operation *op = worklist.pop_back_val();
119-
LLVM_DEBUG(llvm::dbgs() << "processing: " << op->getName() << "\n");
122+
LDBG() << "processing: "
123+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
120124

121125
// If this is a symbol table, recursively compute its liveness.
122126
if (op->hasTrait<OpTrait::SymbolTable>()) {
123127
// The internal symbol table is hidden if the parent is, if its not a
124128
// symbol, or if it is a private symbol.
125129
SymbolOpInterface symbol = dyn_cast<SymbolOpInterface>(op);
126130
bool symIsHidden = symbolTableIsHidden || !symbol || symbol.isPrivate();
127-
LLVM_DEBUG(llvm::dbgs() << "\tsymbol table: " << op->getName()
128-
<< " is hidden: " << symIsHidden << "\n");
131+
LDBG() << "\tsymbol table: "
132+
<< OpWithFlags(op, OpPrintingFlags().skipRegions())
133+
<< " is hidden: " << symIsHidden;
129134
if (failed(computeLiveness(op, symbolTable, symIsHidden, liveSymbols)))
130135
return failure();
131136
} else {
132-
LLVM_DEBUG(llvm::dbgs()
133-
<< "\tnon-symbol table: " << op->getName() << "\n");
137+
LDBG() << "\tnon-symbol table: "
138+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
134139
// If the op is not a symbol table, then, unless op itself is dead which
135140
// would be handled by DCE, we need to check all the regions and blocks
136141
// within the op to find the uses (e.g., consider visibility within op as
@@ -160,20 +165,17 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp,
160165
}
161166

162167
SmallVector<Operation *, 4> resolvedSymbols;
163-
LLVM_DEBUG(llvm::dbgs() << "uses of " << op->getName() << "\n");
168+
LDBG() << "uses of " << OpWithFlags(op, OpPrintingFlags().skipRegions());
164169
for (const SymbolTable::SymbolUse &use : *uses) {
165-
LLVM_DEBUG(llvm::dbgs() << "\tuse: " << use.getUser() << "\n");
170+
LDBG() << "\tuse: " << use.getUser();
166171
// Lookup the symbols referenced by this use.
167172
resolvedSymbols.clear();
168173
if (failed(symbolTable.lookupSymbolIn(parentOp, use.getSymbolRef(),
169174
resolvedSymbols)))
170175
// Ignore references to unknown symbols.
171176
continue;
172-
LLVM_DEBUG({
173-
llvm::dbgs() << "\t\tresolved symbols: ";
174-
llvm::interleaveComma(resolvedSymbols, llvm::dbgs());
175-
llvm::dbgs() << "\n";
176-
});
177+
LDBG() << "\t\tresolved symbols: "
178+
<< llvm::interleaved(resolvedSymbols, ", ");
177179

178180
// Mark each of the resolved symbols as live.
179181
for (Operation *resolvedSymbol : resolvedSymbols)

0 commit comments

Comments
 (0)