|
13 | 13 |
|
14 | 14 | #include "mlir/Transforms/Passes.h" |
15 | 15 |
|
| 16 | +#include "mlir/IR/Operation.h" |
16 | 17 | #include "mlir/IR/SymbolTable.h" |
17 | 18 | #include "llvm/Support/Debug.h" |
| 19 | +#include "llvm/Support/DebugLog.h" |
| 20 | +#include "llvm/Support/InterleavedRange.h" |
18 | 21 |
|
19 | 22 | namespace mlir { |
20 | 23 | #define GEN_PASS_DEF_SYMBOLDCE |
@@ -87,8 +90,8 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp, |
87 | 90 | SymbolTableCollection &symbolTable, |
88 | 91 | bool symbolTableIsHidden, |
89 | 92 | DenseSet<Operation *> &liveSymbols) { |
90 | | - LLVM_DEBUG(llvm::dbgs() << "computeLiveness: " << symbolTableOp->getName() |
91 | | - << "\n"); |
| 93 | + LDBG() << "computeLiveness: " |
| 94 | + << OpWithFlags(symbolTableOp, OpPrintingFlags().skipRegions()); |
92 | 95 | // A worklist of live operations to propagate uses from. |
93 | 96 | SmallVector<Operation *, 16> worklist; |
94 | 97 |
|
@@ -116,21 +119,23 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp, |
116 | 119 | // consideration. |
117 | 120 | while (!worklist.empty()) { |
118 | 121 | Operation *op = worklist.pop_back_val(); |
119 | | - LLVM_DEBUG(llvm::dbgs() << "processing: " << op->getName() << "\n"); |
| 122 | + LDBG() << "processing: " |
| 123 | + << OpWithFlags(op, OpPrintingFlags().skipRegions()); |
120 | 124 |
|
121 | 125 | // If this is a symbol table, recursively compute its liveness. |
122 | 126 | if (op->hasTrait<OpTrait::SymbolTable>()) { |
123 | 127 | // The internal symbol table is hidden if the parent is, if its not a |
124 | 128 | // symbol, or if it is a private symbol. |
125 | 129 | SymbolOpInterface symbol = dyn_cast<SymbolOpInterface>(op); |
126 | 130 | 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; |
129 | 134 | if (failed(computeLiveness(op, symbolTable, symIsHidden, liveSymbols))) |
130 | 135 | return failure(); |
131 | 136 | } else { |
132 | | - LLVM_DEBUG(llvm::dbgs() |
133 | | - << "\tnon-symbol table: " << op->getName() << "\n"); |
| 137 | + LDBG() << "\tnon-symbol table: " |
| 138 | + << OpWithFlags(op, OpPrintingFlags().skipRegions()); |
134 | 139 | // If the op is not a symbol table, then, unless op itself is dead which |
135 | 140 | // would be handled by DCE, we need to check all the regions and blocks |
136 | 141 | // within the op to find the uses (e.g., consider visibility within op as |
@@ -160,20 +165,17 @@ LogicalResult SymbolDCE::computeLiveness(Operation *symbolTableOp, |
160 | 165 | } |
161 | 166 |
|
162 | 167 | SmallVector<Operation *, 4> resolvedSymbols; |
163 | | - LLVM_DEBUG(llvm::dbgs() << "uses of " << op->getName() << "\n"); |
| 168 | + LDBG() << "uses of " << OpWithFlags(op, OpPrintingFlags().skipRegions()); |
164 | 169 | for (const SymbolTable::SymbolUse &use : *uses) { |
165 | | - LLVM_DEBUG(llvm::dbgs() << "\tuse: " << use.getUser() << "\n"); |
| 170 | + LDBG() << "\tuse: " << use.getUser(); |
166 | 171 | // Lookup the symbols referenced by this use. |
167 | 172 | resolvedSymbols.clear(); |
168 | 173 | if (failed(symbolTable.lookupSymbolIn(parentOp, use.getSymbolRef(), |
169 | 174 | resolvedSymbols))) |
170 | 175 | // Ignore references to unknown symbols. |
171 | 176 | 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, ", "); |
177 | 179 |
|
178 | 180 | // Mark each of the resolved symbols as live. |
179 | 181 | for (Operation *resolvedSymbol : resolvedSymbols) |
|
0 commit comments