Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/test/fuzzing.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
'exact-references.wast',
'optimize-instructions-exact.wast',
'local-subtyping-exact.wast',
'remove-unused-types-exact.wast',
]


Expand Down
4 changes: 3 additions & 1 deletion src/ir/type-updating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ void GlobalTypeRewriter::mapTypes(const TypeMap& oldToNewTypes) {

Type getNew(Type type) {
if (type.isRef()) {
return Type(getNew(type.getHeapType()), type.getNullability());
return Type(getNew(type.getHeapType()),
type.getNullability(),
type.getExactness());
}
if (type.isTuple()) {
auto tuple = type.getTuple();
Expand Down
3 changes: 2 additions & 1 deletion src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ struct TypeBuilder {
return t;
}
assert(t.isRef());
return getTempRefType(map(t.getHeapType()), t.getNullability());
return getTempRefType(
map(t.getHeapType()), t.getNullability(), t.getExactness());
};
auto copyType = [&](Type t) -> Type {
if (t.isTuple()) {
Expand Down
16 changes: 16 additions & 0 deletions test/lit/passes/remove-unused-types-exact.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.

;; RUN: wasm-opt %s -all --closed-world --remove-unused-types -S -o - | filecheck %s

;; Test that a simple type rewrite handles exact references in heap type
;; definitions correctly. In particular, the function should continue returning
;; an exact nullref and the call expression should have the same type.

(module
;; CHECK: (func $return-exact (type $0) (result (exact nullref))
;; CHECK-NEXT: (call $return-exact)
;; CHECK-NEXT: )
(func $return-exact (result (exact nullref))
(call $return-exact)
)
)