Skip to content

Commit 81ea94f

Browse files
linuxlonelyeaglejoker-eph
authored andcommitted
Automerge: [mlir][dataflow] Add arguemnt print for test-liveness-analysis (#169625)
Add arguemnt print for test-liveness-analysis to better debug remove-dead-values pass. --------- Co-authored-by: Mehdi Amini <[email protected]>
2 parents c91b66b + 1ff5c89 commit 81ea94f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

mlir/test/Analysis/DataFlow/test-liveness-analysis.mlir

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ func.func private @private0(%0 : i32) -> i32 {
184184
// CHECK-NEXT: result #0: live
185185
// CHECK-LABEL: test_tag: y:
186186
// CHECK-NEXT: result #0: not live
187+
// CHECK-LABEL: test_tag: for:
188+
// CHECK-NEXT: operand #0: live
189+
// CHECK-NEXT: operand #1: live
190+
// CHECK-NEXT: operand #2: live
191+
// CHECK-NEXT: operand #3: live
192+
// CHECK-NEXT: operand #4: not live
193+
// CHECK-NEXT: result #0: live
194+
// CHECK-NEXT: result #1: not live
195+
// CHECK-NEXT: region: #0:
196+
// CHECK-NEXT: argument: #0: live
197+
// CHECK-NEXT: argument: #1: not live
198+
// CHECK-NEXT: argument: #2: not live
187199
func.func @test_7_type_3(%arg0: memref<i32>) {
188200
%c0 = arith.constant {tag = "zero"} 0 : index
189201
%c10 = arith.constant {tag = "ten"} 10 : index
@@ -194,7 +206,7 @@ func.func @test_7_type_3(%arg0: memref<i32>) {
194206
%1 = arith.addi %x, %x : i32
195207
%2 = func.call @private0(%1) : (i32) -> i32
196208
scf.yield %2, %arg3 : i32, i32
197-
}
209+
} {tag = "for"}
198210
memref.store %0#0, %arg0[] : memref<i32>
199211
return
200212
}

mlir/test/lib/Analysis/DataFlow/TestLivenessAnalysis.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ struct TestLivenessAnalysisPass
5656
liveness->print(os);
5757
os << "\n";
5858
}
59+
for (auto [regionIndex, region] : llvm::enumerate(op->getRegions())) {
60+
os << " region: #" << regionIndex << ":\n";
61+
for (auto [argumntIndex, argument] :
62+
llvm::enumerate(region.getArguments())) {
63+
const Liveness *liveness = livenessAnalysis.getLiveness(argument);
64+
assert(liveness && "expected a sparse lattice");
65+
os << " argument: #" << argumntIndex << ": ";
66+
liveness->print(os);
67+
os << "\n";
68+
}
69+
}
5970
});
6071
}
6172
};

0 commit comments

Comments
 (0)