Skip to content

Commit 143fc79

Browse files
committed
[mlir] Changed walk to visit child blocks for each operation
Signed-off-by: ikulagin <[email protected]>
1 parent 8b07872 commit 143fc79

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

mlir/lib/Analysis/Liveness.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,16 @@ struct BlockInfoBuilder {
6767
// Mark all nested operation results as defined, and nested operation
6868
// operands as used. All defined value will be removed from the used set
6969
// at the end.
70-
block->walk([&](Block *nestedBlock) {
71-
if (block != nestedBlock) {
72-
for (BlockArgument arg : nestedBlock->getArguments()) {
73-
defValues.insert(arg);
74-
}
75-
}
76-
for (Operation &op : *nestedBlock) {
77-
for (Value result : op.getResults())
78-
defValues.insert(result);
79-
for (Value operand : op.getOperands())
80-
useValues.insert(operand);
81-
}
70+
block->walk([&](Operation *op) {
71+
for (Value result : op->getResults())
72+
defValues.insert(result);
73+
for (Value operand : op->getOperands())
74+
useValues.insert(operand);
75+
for (Region &region : op->getRegions())
76+
for (Block &child : region.getBlocks())
77+
for (BlockArgument arg : child.getArguments()) {
78+
defValues.insert(arg);
79+
}
8280
});
8381
llvm::set_subtract(useValues, defValues);
8482
}

mlir/test/Analysis/test-liveness.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ func.func @nested_region3(
500500

501501
func.func @nested_region4(%arg0: index, %arg1: index, %arg2: index) {
502502
// CHECK: Block: 0
503-
// CHECK-NEXT: LiveIn:
504-
// CHECK-NEXT: LiveOut:
503+
// CHECK-NEXT: LiveIn:{{ *$}}
504+
// CHECK-NEXT: LiveOut:{{ *$}}
505505
// CHECK-NEXT: BeginLivenessIntervals
506506
// CHECK-NEXT: val_3
507507
// CHECK-NEXT: %c0_i32 = arith.constant 0
@@ -532,7 +532,7 @@ func.func @nested_region4(%arg0: index, %arg1: index, %arg2: index) {
532532
%0 = scf.for %arg3 = %arg0 to %arg1 step %arg2 iter_args(%arg4 = %c0_i32) -> (i32) {
533533
// CHECK-NEXT: Block: 1
534534
// CHECK-NEXT: LiveIn: val_4
535-
// CHECK-NEXT: LiveOut:
535+
// CHECK-NEXT: LiveOut:{{ *$}}
536536
// CHECK-NEXT: BeginLivenessIntervals
537537
// CHECK-NEXT: val_8
538538
// CHECK-NEXT: %1 = arith.addi

0 commit comments

Comments
 (0)