Skip to content

Commit 3407fed

Browse files
[mlir][dataflow] Use skipRegions to print region op (NFC) (#161066)
The print region op prints a lot of useless IR. Use OpWithFlags(op, OpPrintingFlags().skipRegions()) to avoid this.
1 parent 58805dd commit 3407fed

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ LivenessAnalysis::visitOperation(Operation *op, ArrayRef<Liveness *> operands,
109109
foundLiveResult = true;
110110
}
111111
LDBG() << "[visitOperation] Adding dependency for result: " << r
112-
<< " after op: " << *op;
112+
<< " after op: " << OpWithFlags(op, OpPrintingFlags().skipRegions());
113113
addDependency(const_cast<Liveness *>(r), getProgramPointAfter(op));
114114
}
115115
return success();
116116
}
117117

118118
void LivenessAnalysis::visitBranchOperand(OpOperand &operand) {
119+
Operation *op = operand.getOwner();
119120
LDBG() << "Visiting branch operand: " << operand.get()
120-
<< " in op: " << *operand.getOwner();
121+
<< " in op: " << OpWithFlags(op, OpPrintingFlags().skipRegions());
121122
// We know (at the moment) and assume (for the future) that `operand` is a
122123
// non-forwarded branch operand of a `RegionBranchOpInterface`,
123124
// `BranchOpInterface`, `RegionBranchTerminatorOpInterface` or return-like op.
124-
Operation *op = operand.getOwner();
125125
assert((isa<RegionBranchOpInterface>(op) || isa<BranchOpInterface>(op) ||
126126
isa<RegionBranchTerminatorOpInterface>(op)) &&
127127
"expected the op to be `RegionBranchOpInterface`, "
@@ -146,12 +146,13 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) {
146146
// Therefore, if the result value is live, we conservatively consider the
147147
// non-forwarded operand of the region branch operation with result may
148148
// live and record all result.
149-
for (Value result : op->getResults()) {
149+
for (auto [resultIndex, result] : llvm::enumerate(op->getResults())) {
150150
if (getLatticeElement(result)->isLive) {
151151
mayLive = true;
152-
LDBG() << "[visitBranchOperand] Non-forwarded branch "
153-
"operand may be live due to live result: "
154-
<< result;
152+
LDBG() << "[visitBranchOperand] Non-forwarded branch operand may be "
153+
"live due to live result #"
154+
<< resultIndex << ": "
155+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
155156
break;
156157
}
157158
}
@@ -233,7 +234,8 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) {
233234
SmallVector<const Liveness *, 4> resultsLiveness;
234235
for (const Value result : op->getResults())
235236
resultsLiveness.push_back(getLatticeElement(result));
236-
LDBG() << "Visiting operation for non-forwarded branch operand: " << *op;
237+
LDBG() << "Visiting operation for non-forwarded branch operand: "
238+
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
237239
(void)visitOperation(op, operandLiveness, resultsLiveness);
238240

239241
// We also visit the parent op with the parent's results and this operand if

0 commit comments

Comments
 (0)