Skip to content

Commit 9dbc133

Browse files
committed
[MLIR] Improve debug output by avoiding pointer values (NFC)
This makes it easier to diff before/after when doing changes.
1 parent 11b4f11 commit 9dbc133

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "mlir/IR/Diagnostics.h"
1616
#include "mlir/IR/Location.h"
1717
#include "mlir/IR/Operation.h"
18+
#include "mlir/IR/OperationSupport.h"
1819
#include "mlir/IR/SymbolTable.h"
1920
#include "mlir/IR/Value.h"
2021
#include "mlir/IR/ValueRange.h"
@@ -147,7 +148,7 @@ LogicalResult DeadCodeAnalysis::initialize(Operation *top) {
147148

148149
void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) {
149150
LDBG() << "[init] Entering initializeSymbolCallables for top-level op: "
150-
<< top->getName();
151+
<< OpWithFlags(top, OpPrintingFlags().skipRegions());
151152
analysisScope = top;
152153
auto walkFn = [&](Operation *symTable, bool allUsesVisible) {
153154
LDBG() << "[init] Processing symbol table op: " << symTable->getName();
@@ -217,7 +218,7 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) {
217218
SymbolTable::walkSymbolTables(top, /*allSymUsesVisible=*/!top->getBlock(),
218219
walkFn);
219220
LDBG() << "[init] Finished initializeSymbolCallables for top-level op: "
220-
<< top->getName();
221+
<< OpWithFlags(top, OpPrintingFlags().skipRegions());
221222
}
222223

223224
/// Returns true if the operation is a returning terminator in region
@@ -229,8 +230,8 @@ static bool isRegionOrCallableReturn(Operation *op) {
229230
}
230231

231232
LogicalResult DeadCodeAnalysis::initializeRecursively(Operation *op) {
232-
LDBG() << "[init] Entering initializeRecursively for op: " << op->getName()
233-
<< " at " << op;
233+
LDBG() << "[init] Entering initializeRecursively for op: "
234+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
234235
// Initialize the analysis by visiting every op with control-flow semantics.
235236
if (op->getNumRegions() || op->getNumSuccessors() ||
236237
isRegionOrCallableReturn(op) || isa<CallOpInterface>(op)) {
@@ -248,14 +249,14 @@ LogicalResult DeadCodeAnalysis::initializeRecursively(Operation *op) {
248249
for (Region &region : op->getRegions()) {
249250
LDBG() << "[init] Recursing into region of op: " << op->getName();
250251
for (Operation &nestedOp : region.getOps()) {
251-
LDBG() << "[init] Recursing into nested op: " << nestedOp.getName()
252-
<< " at " << &nestedOp;
252+
LDBG() << "[init] Recursing into nested op: "
253+
<< OpWithFlags(&nestedOp, OpPrintingFlags().skipRegions());
253254
if (failed(initializeRecursively(&nestedOp)))
254255
return failure();
255256
}
256257
}
257-
LDBG() << "[init] Finished initializeRecursively for op: " << op->getName()
258-
<< " at " << op;
258+
LDBG() << "[init] Finished initializeRecursively for op: "
259+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
259260
return success();
260261
}
261262

@@ -281,7 +282,7 @@ void DeadCodeAnalysis::markEntryBlocksLive(Operation *op) {
281282
}
282283

283284
LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) {
284-
LDBG() << "Visiting program point: " << point << " " << *point;
285+
LDBG() << "Visiting program point: " << *point;
285286
if (point->isBlockStart())
286287
return success();
287288
Operation *op = point->getPrevOp();
@@ -382,14 +383,14 @@ void DeadCodeAnalysis::visitCallOperation(CallOpInterface call) {
382383
getOrCreate<PredecessorState>(getProgramPointAfter(callableOp));
383384
propagateIfChanged(callsites, callsites->join(call));
384385
LDBG() << "Added callsite as predecessor for callable: "
385-
<< callableOp->getName();
386+
<< OpWithFlags(callableOp, OpPrintingFlags().skipRegions());
386387
} else {
387388
// Mark this call op's predecessors as overdefined.
388389
auto *predecessors =
389390
getOrCreate<PredecessorState>(getProgramPointAfter(call));
390391
propagateIfChanged(predecessors, predecessors->setHasUnknownPredecessors());
391392
LDBG() << "Marked call op's predecessors as unknown for: "
392-
<< call.getOperation()->getName();
393+
<< OpWithFlags(call.getOperation(), OpPrintingFlags().skipRegions());
393394
}
394395
}
395396

@@ -421,7 +422,8 @@ DeadCodeAnalysis::getOperandValues(Operation *op) {
421422
}
422423

423424
void DeadCodeAnalysis::visitBranchOperation(BranchOpInterface branch) {
424-
LDBG() << "visitBranchOperation: " << branch.getOperation()->getName();
425+
LDBG() << "visitBranchOperation: "
426+
<< OpWithFlags(branch.getOperation(), OpPrintingFlags().skipRegions());
425427
// Try to deduce a single successor for the branch.
426428
std::optional<SmallVector<Attribute>> operands = getOperandValues(branch);
427429
if (!operands)

0 commit comments

Comments
 (0)