From c1b481a8717bd0aeb4a271f8fa5d31a6887f697c Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Sun, 12 Nov 2023 20:47:20 -0800 Subject: [PATCH] add extra debug statements --- lib/Transform/Noisy/ReduceNoiseOptimizer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp b/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp index 09c9061..b86a8d4 100644 --- a/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp +++ b/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp @@ -8,11 +8,14 @@ #include "mlir/include/mlir/Analysis/DataFlowFramework.h" #include "mlir/include/mlir/IR/Visitors.h" #include "mlir/include/mlir/Pass/Pass.h" +#include "llvm/Support/Debug.h" namespace mlir { namespace tutorial { namespace noisy { +#define DEBUG_TYPE "ReduceNoiseOptimizer" + #define GEN_PASS_DEF_REDUCENOISEOPTIMIZER #include "lib/Transform/Noisy/Passes.h.inc" @@ -43,8 +46,11 @@ struct ReduceNoiseOptimizer // dependence is not automatic and fails silently. solver.load(); solver.load(); - if (failed(solver.initializeAndRun(module))) + if (failed(solver.initializeAndRun(module))) { + getOperation()->emitOpError() << "Failed to run the analysis.\n"; signalPassFailure(); + return; + } auto result = module->walk([&](Operation *op) { if (!llvm::isagetValue().getValue(); + LLVM_DEBUG(llvm::dbgs() << "op " << *op << " has error range [" + << range.umin().getZExtValue() << ", " + << range.umax().getZExtValue() << "]\n"); if (range.umax().getZExtValue() > MAX_NOISE) { op->emitOpError() << "Found op after which the noise exceeds the " "allowable maximum of " @@ -73,8 +82,11 @@ struct ReduceNoiseOptimizer return WalkResult::advance(); }); - if (result.wasInterrupted()) + if (result.wasInterrupted()) { + getOperation()->emitOpError() + << "Detected error in the noise analysis.\n"; signalPassFailure(); + } } };