[Mlir-commits] [mlir] [MLIR] Add more logging to DenseAnalysis/DeaDCodeAnalysis/TestDenseBackwardDataFlowAnalysis (NFC) (PR #161503)
    Mehdi Amini 
    llvmlistbot at llvm.org
       
    Mon Oct  6 13:56:42 PDT 2025
    
    
  
================
@@ -256,64 +357,109 @@ void AbstractDenseForwardDataFlowAnalysis::visitRegionBranchOperation(
 
 void AbstractDenseBackwardDataFlowAnalysis::initializeEquivalentLatticeAnchor(
     Operation *top) {
+  LDBG() << "initializeEquivalentLatticeAnchor (backward): "
+         << OpWithFlags(top, OpPrintingFlags().skipRegions());
   top->walk([&](Operation *op) {
-    if (isa<RegionBranchOpInterface, CallOpInterface>(op))
+    if (isa<RegionBranchOpInterface, CallOpInterface>(op)) {
+      LDBG() << "  Skipping "
+             << OpWithFlags(op, OpPrintingFlags().skipRegions())
+             << " (region branch or call)";
       return;
+    }
+    LDBG() << "  Building equivalent lattice anchor for "
+           << OpWithFlags(op, OpPrintingFlags().skipRegions());
     buildOperationEquivalentLatticeAnchor(op);
   });
 }
 
 LogicalResult
 AbstractDenseBackwardDataFlowAnalysis::initialize(Operation *top) {
+  LDBG() << "initialize (backward): "
+         << OpWithFlags(top, OpPrintingFlags().skipRegions());
   // Visit every operation and block.
-  if (failed(processOperation(top)))
+  if (failed(processOperation(top))) {
+    LDBG() << "  Failed to process top-level operation";
     return failure();
+  }
 
   for (Region ®ion : top->getRegions()) {
+    LDBG() << "  Processing region with " << region.getBlocks().size()
+           << " blocks";
     for (Block &block : region) {
+      LDBG() << "    Processing block with " << block.getOperations().size()
+             << " operations";
       visitBlock(&block);
       for (Operation &op : llvm::reverse(block)) {
-        if (failed(initialize(&op)))
+        LDBG() << "      Initializing operation (backward): "
+               << OpWithFlags(&op, OpPrintingFlags().skipRegions());
+        if (failed(initialize(&op))) {
+          LDBG() << "      Failed to initialize operation";
           return failure();
+        }
       }
     }
   }
+  LDBG() << "  Backward initialization completed successfully";
   return success();
 }
 
 LogicalResult
 AbstractDenseBackwardDataFlowAnalysis::visit(ProgramPoint *point) {
-  if (!point->isBlockEnd())
+  LDBG() << "visit (backward): " << *point;
+  if (!point->isBlockEnd()) {
+    LDBG() << "  Processing operation: "
+           << OpWithFlags(point->getNextOp(), OpPrintingFlags().skipRegions());
     return processOperation(point->getNextOp());
+  }
+  LDBG() << "  Visiting block: " << point->getBlock();
   visitBlock(point->getBlock());
   return success();
 }
 
 void AbstractDenseBackwardDataFlowAnalysis::visitCallOperation(
     CallOpInterface call, const AbstractDenseLattice &after,
     AbstractDenseLattice *before) {
+  LDBG() << "visitCallOperation (backward): "
+         << OpWithFlags(call.getOperation(), OpPrintingFlags().skipRegions());
+  LDBG() << "  after state: " << after;
+  LDBG() << "  before state: " << *before;
----------------
joker-eph wrote:
I wasn't sure, it felt like something to tweak when iterating on examples and wanting to filter out things. For my debugging session it didn't seem to bother me.
It looks like this right now:
```
[dense-analysis DenseAnalysis.cpp:408 1] visit (backward): <after operation>:%0 = memref.load %arg0[] {name = "pre"} : memref<f32>
[dense-analysis DenseAnalysis.cpp:410 1]   Processing operation: func.call_indirect %arg1(%arg0) {name = "call"} : (memref<f32>) -> ()
[dense-analysis DenseAnalysis.cpp:489 1] processOperation (backward): func.call_indirect %arg1(%arg0) {name = "call"} : (memref<f32>) -> ()
[dense-analysis DenseAnalysis.cpp:506 1]   before state: 
[dense-analysis DenseAnalysis.cpp:507 1]   after state: <block argument> of type 'memref<f32>' at index: 0:
[dense-analysis DenseAnalysis.cpp:507 1]   %1 = memref.load %arg0[] {name = "post"} : memref<f32>
[dense-analysis DenseAnalysis.cpp:517 1]   Processing as call operation
[dense-analysis DenseAnalysis.cpp:422 1] visitCallOperation (backward): func.call_indirect %arg1(%arg0) {name = "call"} : (memref<f32>) -> ()
[dense-analysis DenseAnalysis.cpp:424 1]   after state: <block argument> of type 'memref<f32>' at index: 0:
[dense-analysis DenseAnalysis.cpp:424 1]   %1 = memref.load %arg0[] {name = "post"} : memref<f32>
[dense-analysis DenseAnalysis.cpp:425 1]   before state: 
[dense-analysis DenseAnalysis.cpp:441 1]   Resolved callee: null
[dense-analysis DenseAnalysis.cpp:457 1]   No callable found, setting to exit state
```
https://github.com/llvm/llvm-project/pull/161503
    
    
More information about the Mlir-commits
mailing list