summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/RemoveUnusedBrs.cpp2
-rw-r--r--test/passes/remove-unused-brs_all-features.txt17
-rw-r--r--test/passes/remove-unused-brs_all-features.wast16
3 files changed, 34 insertions, 1 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 5d236211b..eaf681a08 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -993,7 +993,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
return nullptr;
}
return Builder(*getModule())
- .makeSelect(iff->condition, iff->ifTrue, iff->ifFalse);
+ .makeSelect(iff->condition, iff->ifTrue, iff->ifFalse, iff->type);
}
void visitLocalSet(LocalSet* curr) {
diff --git a/test/passes/remove-unused-brs_all-features.txt b/test/passes/remove-unused-brs_all-features.txt
index 3365ebb75..f8308c65f 100644
--- a/test/passes/remove-unused-brs_all-features.txt
+++ b/test/passes/remove-unused-brs_all-features.txt
@@ -1,8 +1,12 @@
(module
(type $struct (struct (field (ref null $vector))))
(type $vector (array (mut i32)))
+ (type $i32_=>_none (func (param i32)))
+ (type $none_=>_i32 (func (result i32)))
(type $none_=>_f64 (func (result f64)))
+ (type $i32_=>_funcref (func (param i32) (result funcref)))
(type $none_=>_ref?|$struct| (func (result (ref null $struct))))
+ (elem declare func $i32_=>_none $none_=>_i32)
(func $foo (result (ref null $struct))
(if (result (ref null $struct))
(i32.const 1)
@@ -33,4 +37,17 @@
)
)
)
+ (func $none_=>_i32 (result i32)
+ (unreachable)
+ )
+ (func $i32_=>_none (param $0 i32)
+ (nop)
+ )
+ (func $selectify (param $x i32) (result funcref)
+ (select (result funcref)
+ (ref.func $none_=>_i32)
+ (ref.func $i32_=>_none)
+ (local.get $x)
+ )
+ )
)
diff --git a/test/passes/remove-unused-brs_all-features.wast b/test/passes/remove-unused-brs_all-features.wast
index 3703bb9f2..1da00291d 100644
--- a/test/passes/remove-unused-brs_all-features.wast
+++ b/test/passes/remove-unused-brs_all-features.wast
@@ -16,6 +16,7 @@
(ref.null $struct)
)
)
+
(func $test-prefinalize (result f64)
(loop $loop (result f64)
(block $block (result f64)
@@ -37,4 +38,19 @@
)
)
)
+
+ (func $none_=>_i32 (result i32)
+ (unreachable)
+ )
+ (func $i32_=>_none (param i32)
+ )
+ (func $selectify (param $x i32) (result funcref)
+ ;; this if has arms with different function types, for which funcref is the
+ ;; LUB
+ (if (result funcref)
+ (local.get $x)
+ (ref.func $none_=>_i32)
+ (ref.func $i32_=>_none)
+ )
+ )
)