Skip to content

Commit 195d757

Browse files
committed
Walk in pre-order. Rebase to clean-up windows build issue.
1 parent 626f44f commit 195d757

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

mlir/lib/IR/Builders.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,15 @@ LogicalResult OpBuilder::tryFold(Operation *op,
528528
Operation *OpBuilder::clone(Operation &op, IRMapping &mapper) {
529529
Operation *newOp = op.clone(mapper);
530530
newOp = insert(newOp);
531-
// The `insert` call below handles the notification for inserting `newOp`
531+
// The `insert` call above handles the notification for inserting `newOp`
532532
// itself. But if `newOp` has any regions, we need to notify the listener
533533
// about any ops that got inserted inside those regions as part of cloning.
534534
if (listener) {
535535
auto walkFn = [&](Operation *walkedOp) {
536536
listener->notifyOperationInserted(walkedOp);
537537
};
538538
for (Region &region : newOp->getRegions())
539-
region.walk(walkFn);
539+
region.walk<WalkOrder::PreOrder>(walkFn);
540540
}
541541
return newOp;
542542
}

mlir/test/IR/test-clone.mlir

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,33 @@
33
module {
44
func.func @fixpoint(%arg1 : i32) -> i32 {
55
%r = "test.use"(%arg1) ({
6-
"test.yield"(%arg1) : (i32) -> ()
6+
%r2 = "test.use2"(%arg1) ({
7+
"test.yield2"(%arg1) : (i32) -> ()
8+
}) : (i32) -> i32
9+
"test.yield"(%r2) : (i32) -> ()
710
}) : (i32) -> i32
811
return %r : i32
912
}
1013
}
1114

1215
// CHECK: notifyOperationInserted: test.use
16+
// CHECK-NEXT: notifyOperationInserted: test.use2
17+
// CHECK-NEXT: notifyOperationInserted: test.yield2
1318
// CHECK-NEXT: notifyOperationInserted: test.yield
1419
// CHECK-NEXT: notifyOperationInserted: func.return
1520

1621
// CHECK: func @fixpoint(%[[arg0:.+]]: i32) -> i32 {
1722
// CHECK-NEXT: %[[i0:.+]] = "test.use"(%[[arg0]]) ({
18-
// CHECK-NEXT: "test.yield"(%arg0) : (i32) -> ()
23+
// CHECK-NEXT: %[[r2:.+]] = "test.use2"(%[[arg0]]) ({
24+
// CHECK-NEXT: "test.yield2"(%[[arg0]]) : (i32) -> ()
25+
// CHECK-NEXT: }) : (i32) -> i32
26+
// CHECK-NEXT: "test.yield"(%[[r2]]) : (i32) -> ()
1927
// CHECK-NEXT: }) : (i32) -> i32
2028
// CHECK-NEXT: %[[i1:.+]] = "test.use"(%[[i0]]) ({
21-
// CHECK-NEXT: "test.yield"(%[[i0]]) : (i32) -> ()
29+
// CHECK-NEXT: %[[r2:.+]] = "test.use2"(%[[i0]]) ({
30+
// CHECK-NEXT: "test.yield2"(%[[i0]]) : (i32) -> ()
31+
// CHECK-NEXT: }) : (i32) -> i32
32+
// CHECK-NEXT: "test.yield"(%[[r2]]) : (i32) -> ()
2233
// CHECK-NEXT: }) : (i32) -> i32
2334
// CHECK-NEXT: return %[[i1]] : i32
2435
// CHECK-NEXT: }

0 commit comments

Comments
 (0)