summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/SignatureRefining.cpp11
-rw-r--r--test/lit/passes/signature-refining.wast38
2 files changed, 40 insertions, 9 deletions
diff --git a/src/passes/SignatureRefining.cpp b/src/passes/SignatureRefining.cpp
index de669dbb2..281214e32 100644
--- a/src/passes/SignatureRefining.cpp
+++ b/src/passes/SignatureRefining.cpp
@@ -156,8 +156,6 @@ struct SignatureRefining : public Pass {
}
}
- bool refinedResults = false;
-
// Compute optimal LUBs.
std::unordered_set<HeapType> seen;
for (auto& func : module->functions) {
@@ -225,8 +223,6 @@ struct SignatureRefining : public Pass {
newSignatures[type] = Signature(newParams, newResults);
if (newResults != func->getResults()) {
- refinedResults = true;
-
// Update the types of calls using the signature.
for (auto* call : info.calls) {
if (call->type != Type::unreachable) {
@@ -288,11 +284,8 @@ struct SignatureRefining : public Pass {
// Rewrite the types.
GlobalTypeRewriter::updateSignatures(newSignatures, *module);
- if (refinedResults) {
- // After return types change we need to propagate.
- // TODO: we could do this only in relevant functions perhaps
- ReFinalize().run(getPassRunner(), module);
- }
+ // TODO: we could do this only in relevant functions perhaps
+ ReFinalize().run(getPassRunner(), module);
}
};
diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast
index 11bc84f35..996adf658 100644
--- a/test/lit/passes/signature-refining.wast
+++ b/test/lit/passes/signature-refining.wast
@@ -850,3 +850,41 @@
)
)
)
+
+(module
+ ;; CHECK: (rec
+ ;; CHECK-NEXT: (type $ref|$[i8]|_=>_none (func (param (ref $[i8]))))
+
+ ;; CHECK: (type $[i8] (array i8))
+ (type $[i8] (array i8))
+
+ ;; CHECK: (type $none_=>_none (func))
+
+ ;; CHECK: (func $0 (type $none_=>_none)
+ ;; CHECK-NEXT: (call $1
+ ;; CHECK-NEXT: (array.new_fixed $[i8])
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $0
+ (call $1
+ (array.new_fixed $[i8])
+ )
+ )
+
+ ;; CHECK: (func $1 (type $ref|$[i8]|_=>_none) (param $2 (ref $[i8]))
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.cast struct
+ ;; CHECK-NEXT: (local.get $2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $1 (param $2 anyref)
+ ;; The param will become non-nullable after we refine. We must refinalize
+ ;; after doing so, so the cast becomes non-nullable as well.
+ (drop
+ (ref.cast null struct
+ (local.get $2)
+ )
+ )
+ )
+) ;; TODO