diff options
-rw-r--r-- | src/passes/SSAify.cpp | 3 | ||||
-rw-r--r-- | test/lit/passes/ssa.wast | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/passes/SSAify.cpp b/src/passes/SSAify.cpp index a0bdb4152..843015936 100644 --- a/src/passes/SSAify.cpp +++ b/src/passes/SSAify.cpp @@ -53,6 +53,7 @@ #include "ir/find_all.h" #include "ir/literal-utils.h" #include "ir/local-graph.h" +#include "ir/type-updating.h" #include "pass.h" #include "support/permutations.h" #include "wasm-builder.h" @@ -98,6 +99,8 @@ struct SSAify : public Pass { computeGetsAndPhis(graph); // add prepends to function addPrepends(); + // Handle non-nullability in new locals we added. + TypeUpdating::handleNonNullableLocals(func, *module); } void createNewIndexes(LocalGraph& graph) { diff --git a/test/lit/passes/ssa.wast b/test/lit/passes/ssa.wast new file mode 100644 index 000000000..6be5ee11a --- /dev/null +++ b/test/lit/passes/ssa.wast @@ -0,0 +1,34 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s -all --ssa -S -o - | filecheck %s + +(module + (func $foo) + ;; CHECK: (func $bar (param $x (ref func)) + ;; CHECK-NEXT: (local $1 funcref) + ;; CHECK-NEXT: (local $2 funcref) + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (ref.func $foo) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $2 + ;; CHECK-NEXT: (ref.func $bar) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $bar (param $x (ref func)) + ;; assign a non-nullable parameter multiple times, which causes ssa to create + ;; new locals so that each is assigned only once + (local.set $x (ref.func $foo)) + (drop (local.get $x)) + (local.set $x (ref.func $bar)) + (drop (local.get $x)) + ) +) |