Skip to content

Commit e7edd34

Browse files
committed
work
1 parent 8725169 commit e7edd34

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/passes/Flatten.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ struct LowerUnflattenable : public PostWalker<LowerUnflattenable> {
9191
case BrOnNull: {
9292
condition = builder.makeRefIsNull(refTee);
9393
brValue = nullptr;
94-
flowValue = getRef();
94+
flowValue = builder.makeRefAs(RefAsNonNull, getRef());
9595
break;
9696
}
9797
case BrOnNonNull: {
9898
condition = builder.makeRefIsNull(refTee);
9999
flip = true;
100100
brValue = builder.makeRefAs(RefAsNonNull, getRef());
101-
flowValue = builder.makeRefAs(RefAsNonNull, getRef());
101+
flowValue = getRef();
102102
break;
103103
}
104104
case BrOnCast: {

test/lit/passes/flatten-gc.wast

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
;; CHECK: (type $B (sub $A (struct)))
1010
(type $B (sub $A (struct)))
1111

12+
(func $br_on_null (param $x (ref null $A)) (result (ref $A))
13+
(block $non-null (result (ref $A))
14+
(block $block
15+
(return
16+
(br_on_null $block
17+
(local.get $x)
18+
)
19+
)
20+
)
21+
(unreachable)
22+
)
23+
)
24+
1225
;; CHECK: (func $br_on_non_null (type $2) (param $x (ref null $A)) (result (ref $A))
1326
;; CHECK-NEXT: (local $1 (ref null $A))
1427
;; CHECK-NEXT: (local $2 (ref null $A))

0 commit comments

Comments
 (0)