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
7 changes: 5 additions & 2 deletions src/ir/child-typer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,11 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
Type type = ht->getArray().element.type;
note(&curr->ref, Type(*ht, Nullable));
note(&curr->index, Type::i32);
// TODO: (shared eq) as appropriate.
note(&curr->expected, type.isRef() ? Type(HeapType::eq, Nullable) : type);
note(
&curr->expected,
type.isRef()
? Type(HeapTypes::eq.getBasic(type.getHeapType().getShared()), Nullable)
: type);
note(&curr->replacement, type);
}

Expand Down
55 changes: 55 additions & 0 deletions test/lit/basic/gc-atomics-shared.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.

;; RUN: wasm-opt -all %s -S -o - | filecheck %s

;; Check that we properly parse array.atomic.rmw.cmpxchg of a shared array,
;; when the instruction is unreachable (when the the expected field does not
;; have the correct sharedness).

(module
;; CHECK: (type $array (shared (array (mut (ref null (shared eq))))))
(type $array (shared (array (mut (ref null (shared eq))))))

;; CHECK: (global $g (ref $array) (array.new_default $array
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: ))
(global $g (ref $array) (array.new_default $array (i32.const 0)))

;; CHECK: (func $test (type $1) (result (ref null (shared eq)))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (global.get $g)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (block ;; (replaces unreachable ArrayCmpxchg we can't emit)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (result (ref null (shared eq)))
(array.atomic.rmw.cmpxchg acqrel acqrel $array
(global.get $g)
(i32.const 0)
(ref.as_non_null (ref.null none))
(unreachable)
)
)
)

Loading