Skip to content

Commit 5983d7d

Browse files
authored
Migrate more of DataFlow framework to LDBG (NFC) (#150752)
1 parent c28dfa1 commit 5983d7d

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/STLExtras.h"
1717
#include "llvm/Support/Casting.h"
1818
#include "llvm/Support/Debug.h"
19+
#include "llvm/Support/DebugLog.h"
1920
#include <cassert>
2021

2122
#define DEBUG_TYPE "constant-propagation"
@@ -46,7 +47,7 @@ void ConstantValue::print(raw_ostream &os) const {
4647
LogicalResult SparseConstantPropagation::visitOperation(
4748
Operation *op, ArrayRef<const Lattice<ConstantValue> *> operands,
4849
ArrayRef<Lattice<ConstantValue> *> results) {
49-
LLVM_DEBUG(llvm::dbgs() << "SCP: Visiting operation: " << *op << "\n");
50+
LDBG() << "SCP: Visiting operation: " << *op;
5051

5152
// Don't try to simulate the results of a region operation as we can't
5253
// guarantee that folding will be out-of-place. We don't allow in-place
@@ -98,12 +99,11 @@ LogicalResult SparseConstantPropagation::visitOperation(
9899
// Merge in the result of the fold, either a constant or a value.
99100
OpFoldResult foldResult = std::get<1>(it);
100101
if (Attribute attr = llvm::dyn_cast_if_present<Attribute>(foldResult)) {
101-
LLVM_DEBUG(llvm::dbgs() << "Folded to constant: " << attr << "\n");
102+
LDBG() << "Folded to constant: " << attr;
102103
propagateIfChanged(lattice,
103104
lattice->join(ConstantValue(attr, op->getDialect())));
104105
} else {
105-
LLVM_DEBUG(llvm::dbgs()
106-
<< "Folded to value: " << cast<Value>(foldResult) << "\n");
106+
LDBG() << "Folded to value: " << cast<Value>(foldResult);
107107
AbstractSparseForwardDataFlowAnalysis::join(
108108
lattice, *getLatticeElement(cast<Value>(foldResult)));
109109
}

mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ RunLivenessAnalysis::RunLivenessAnalysis(Operation *op) {
294294
solver.load<LivenessAnalysis>(symbolTable);
295295
LDBG() << "Initializing and running solver";
296296
(void)solver.initializeAndRun(op);
297-
LDBG() << "Dumping liveness state for op";
297+
LDBG() << "RunLivenessAnalysis initialized for op: " << op->getName();
298298
}
299299

300300
const Liveness *RunLivenessAnalysis::getLiveness(Value val) {

mlir/lib/Analysis/DataFlowFramework.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "llvm/ADT/iterator.h"
1515
#include "llvm/Config/abi-breaking.h"
1616
#include "llvm/Support/Casting.h"
17-
#include "llvm/Support/Debug.h"
17+
#include "llvm/Support/DebugLog.h"
1818
#include "llvm/Support/raw_ostream.h"
1919

2020
#define DEBUG_TYPE "dataflow"
@@ -44,9 +44,8 @@ void AnalysisState::addDependency(ProgramPoint *dependent,
4444
(void)inserted;
4545
DATAFLOW_DEBUG({
4646
if (inserted) {
47-
llvm::dbgs() << "Creating dependency between " << debugName << " of "
48-
<< anchor << "\nand " << debugName << " on " << dependent
49-
<< "\n";
47+
LDBG() << "Creating dependency between " << debugName << " of " << anchor
48+
<< "\nand " << debugName << " on " << dependent;
5049
}
5150
});
5251
}
@@ -116,8 +115,7 @@ LogicalResult DataFlowSolver::initializeAndRun(Operation *top) {
116115

117116
// Initialize the analyses.
118117
for (DataFlowAnalysis &analysis : llvm::make_pointee_range(childAnalyses)) {
119-
DATAFLOW_DEBUG(llvm::dbgs()
120-
<< "Priming analysis: " << analysis.debugName << "\n");
118+
DATAFLOW_DEBUG(LDBG() << "Priming analysis: " << analysis.debugName);
121119
if (failed(analysis.initialize(top)))
122120
return failure();
123121
}
@@ -129,8 +127,8 @@ LogicalResult DataFlowSolver::initializeAndRun(Operation *top) {
129127
auto [point, analysis] = worklist.front();
130128
worklist.pop();
131129

132-
DATAFLOW_DEBUG(llvm::dbgs() << "Invoking '" << analysis->debugName
133-
<< "' on: " << point << "\n");
130+
DATAFLOW_DEBUG(LDBG() << "Invoking '" << analysis->debugName
131+
<< "' on: " << point);
134132
if (failed(analysis->visit(point)))
135133
return failure();
136134
}
@@ -143,9 +141,9 @@ void DataFlowSolver::propagateIfChanged(AnalysisState *state,
143141
assert(isRunning &&
144142
"DataFlowSolver is not running, should not use propagateIfChanged");
145143
if (changed == ChangeResult::Change) {
146-
DATAFLOW_DEBUG(llvm::dbgs() << "Propagating update to " << state->debugName
147-
<< " of " << state->anchor << "\n"
148-
<< "Value: " << *state << "\n");
144+
DATAFLOW_DEBUG(LDBG() << "Propagating update to " << state->debugName
145+
<< " of " << state->anchor << "\n"
146+
<< "Value: " << *state);
149147
state->onUpdate(this);
150148
}
151149
}

0 commit comments

Comments
 (0)