|
38 | 38 | #include "llvm/ADT/StringSet.h"
|
39 | 39 | #include "llvm/ADT/TypeSwitch.h"
|
40 | 40 | #include "llvm/Support/CommandLine.h"
|
| 41 | +#include "llvm/Support/Debug.h" |
41 | 42 | #include "llvm/Support/Endian.h"
|
42 | 43 | #include "llvm/Support/Regex.h"
|
43 | 44 | #include "llvm/Support/SaveAndRestore.h"
|
|
48 | 49 | using namespace mlir;
|
49 | 50 | using namespace mlir::detail;
|
50 | 51 |
|
| 52 | +#define DEBUG_TYPE "mlir-asm-printer" |
| 53 | + |
51 | 54 | void OperationName::print(raw_ostream &os) const { os << getStringRef(); }
|
52 | 55 |
|
53 | 56 | void OperationName::dump() const { print(llvm::errs()); }
|
@@ -1313,14 +1316,28 @@ static OpPrintingFlags verifyOpAndAdjustFlags(Operation *op,
|
1313 | 1316 | printerFlags.shouldAssumeVerified())
|
1314 | 1317 | return printerFlags;
|
1315 | 1318 |
|
| 1319 | + LLVM_DEBUG(llvm::dbgs() << DEBUG_TYPE << ": Verifying operation: " |
| 1320 | + << op->getName() << "\n"); |
| 1321 | + |
1316 | 1322 | // Ignore errors emitted by the verifier. We check the thread id to avoid
|
1317 | 1323 | // consuming other threads' errors.
|
1318 | 1324 | auto parentThreadId = llvm::get_threadid();
|
1319 |
| - ScopedDiagnosticHandler diagHandler(op->getContext(), [&](Diagnostic &) { |
1320 |
| - return success(parentThreadId == llvm::get_threadid()); |
| 1325 | + ScopedDiagnosticHandler diagHandler(op->getContext(), [&](Diagnostic &diag) { |
| 1326 | + if (parentThreadId == llvm::get_threadid()) { |
| 1327 | + LLVM_DEBUG({ |
| 1328 | + diag.print(llvm::dbgs()); |
| 1329 | + llvm::dbgs() << "\n"; |
| 1330 | + }); |
| 1331 | + return success(); |
| 1332 | + } |
| 1333 | + return failure(); |
1321 | 1334 | });
|
1322 |
| - if (failed(verify(op))) |
| 1335 | + if (failed(verify(op))) { |
| 1336 | + LLVM_DEBUG(llvm::dbgs() |
| 1337 | + << DEBUG_TYPE << ": '" << op->getName() |
| 1338 | + << "' failed to verify and will be printed in generic form\n"); |
1323 | 1339 | printerFlags.printGenericOpForm();
|
| 1340 | + } |
1324 | 1341 |
|
1325 | 1342 | return printerFlags;
|
1326 | 1343 | }
|
|
0 commit comments