Skip to content

Commit 874a453

Browse files
committed
[MLIR] Adopt LDBG() in Transform/IR/Utils.cpp (NFC)
1 parent 5928619 commit 874a453

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

mlir/lib/Dialect/Transform/IR/Utils.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mlir/IR/Verifier.h"
1212
#include "mlir/Interfaces/FunctionInterfaces.h"
1313
#include "llvm/Support/Debug.h"
14+
#include "llvm/Support/DebugLog.h"
1415

1516
using namespace mlir;
1617

@@ -90,7 +91,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
9091
//
9192
// Rename private symbols in both ops in order to resolve conflicts that can
9293
// be resolved that way.
93-
LLVM_DEBUG(DBGS() << "renaming private symbols to resolve conflicts:\n");
94+
LDBG() << "renaming private symbols to resolve conflicts:";
9495
// TODO: Do we *actually* need to test in both directions?
9596
for (auto &&[symbolTable, otherSymbolTable] : llvm::zip(
9697
SmallVector<SymbolTable *, 2>{&targetSymbolTable, &otherSymbolTable},
@@ -102,15 +103,15 @@ transform::detail::mergeSymbolsInto(Operation *target,
102103
if (!symbolOp)
103104
continue;
104105
StringAttr name = symbolOp.getNameAttr();
105-
LLVM_DEBUG(DBGS() << " found @" << name.getValue() << "\n");
106+
LDBG() << " found @" << name.getValue();
106107

107108
// Check if there is a colliding op in the other module.
108109
auto collidingOp =
109110
cast_or_null<SymbolOpInterface>(otherSymbolTable->lookup(name));
110111
if (!collidingOp)
111112
continue;
112113

113-
LLVM_DEBUG(DBGS() << " collision found for @" << name.getValue());
114+
LDBG() << " collision found for @" << name.getValue();
114115

115116
// Collisions are fine if both opt are functions and can be merged.
116117
if (auto funcOp = dyn_cast<FunctionOpInterface>(op),
@@ -119,21 +120,20 @@ transform::detail::mergeSymbolsInto(Operation *target,
119120
funcOp && collidingFuncOp) {
120121
if (canMergeInto(funcOp, collidingFuncOp) ||
121122
canMergeInto(collidingFuncOp, funcOp)) {
122-
LLVM_DEBUG(llvm::dbgs() << " but both ops are functions and "
123-
"will be merged\n");
123+
LDBG() << " but both ops are functions and will be merged";
124124
continue;
125125
}
126126

127127
// If they can't be merged, proceed like any other collision.
128-
LLVM_DEBUG(llvm::dbgs() << " and both ops are function definitions");
128+
LDBG() << " and both ops are function definitions";
129129
}
130130

131131
// Collision can be resolved by renaming if one of the ops is private.
132132
auto renameToUnique =
133133
[&](SymbolOpInterface op, SymbolOpInterface otherOp,
134134
SymbolTable &symbolTable,
135135
SymbolTable &otherSymbolTable) -> InFlightDiagnostic {
136-
LLVM_DEBUG(llvm::dbgs() << ", renaming\n");
136+
LDBG() << ", renaming";
137137
FailureOr<StringAttr> maybeNewName =
138138
symbolTable.renameToUnique(op, {&otherSymbolTable});
139139
if (failed(maybeNewName)) {
@@ -142,8 +142,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
142142
<< "attempted renaming due to collision with this op";
143143
return diag;
144144
}
145-
LLVM_DEBUG(DBGS() << " renamed to @" << maybeNewName->getValue()
146-
<< "\n");
145+
LDBG() << " renamed to @" << maybeNewName->getValue();
147146
return InFlightDiagnostic();
148147
};
149148

@@ -161,7 +160,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
161160
return diag;
162161
continue;
163162
}
164-
LLVM_DEBUG(llvm::dbgs() << ", emitting error\n");
163+
LDBG() << ", emitting error";
165164
InFlightDiagnostic diag = symbolOp.emitError()
166165
<< "doubly defined symbol @" << name.getValue();
167166
diag.attachNote(collidingOp->getLoc()) << "previously defined here";
@@ -179,7 +178,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
179178
// Step 2:
180179
//
181180
// Move all ops from `other` into target and merge public symbols.
182-
LLVM_DEBUG(DBGS() << "moving all symbols into target\n");
181+
LDBG() << "moving all symbols into target";
183182
{
184183
SmallVector<SymbolOpInterface> opsToMove;
185184
for (Operation &op : other->getRegion(0).front()) {
@@ -193,13 +192,13 @@ transform::detail::mergeSymbolsInto(Operation *target,
193192
targetSymbolTable.lookup(op.getNameAttr()));
194193

195194
// Move op even if we get a collision.
196-
LLVM_DEBUG(DBGS() << " moving @" << op.getName());
195+
LDBG() << " moving @" << op.getName();
197196
op->moveBefore(&target->getRegion(0).front(),
198197
target->getRegion(0).front().end());
199198

200199
// If there is no collision, we are done.
201200
if (!collidingOp) {
202-
LLVM_DEBUG(llvm::dbgs() << " without collision\n");
201+
LDBG() << " without collision";
203202
continue;
204203
}
205204

@@ -217,9 +216,9 @@ transform::detail::mergeSymbolsInto(Operation *target,
217216
}
218217
assert(canMergeInto(funcOp, collidingFuncOp));
219218

220-
LLVM_DEBUG(llvm::dbgs() << " with collision, trying to keep op at "
221-
<< collidingFuncOp.getLoc() << ":\n"
222-
<< collidingFuncOp << "\n");
219+
LDBG() << " with collision, trying to keep op at "
220+
<< collidingFuncOp.getLoc() << ":\n"
221+
<< collidingFuncOp;
223222

224223
// Update symbol table. This works with or without the previous `swap`.
225224
targetSymbolTable.remove(funcOp);
@@ -239,6 +238,6 @@ transform::detail::mergeSymbolsInto(Operation *target,
239238
return target->emitError()
240239
<< "failed to verify target op after merging symbols";
241240

242-
LLVM_DEBUG(DBGS() << "done merging ops\n");
241+
LDBG() << "done merging ops";
243242
return InFlightDiagnostic();
244243
}

0 commit comments

Comments
 (0)