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
3 changes: 3 additions & 0 deletions src/ir/subtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ struct SubTypes {
depths[HeapTypes::nofunc.getBasic(share)] = 0;
depths[HeapTypes::nocont.getBasic(share)] = 0;
depths[HeapTypes::noexn.getBasic(share)] = 0;
depths[HeapTypes::sharedNowaitqueue.getBasic(share)] = 0;

depths[HeapTypes::sharedWaitqueue.getBasic(share)] = 1;

// func would appear already if we saw function types, but if not, ensure
// it exists here. Ditto for cont.
Expand Down
46 changes: 46 additions & 0 deletions test/lit/passes/gufa-waitqueue.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s -all --gufa -S -o - | filecheck %s

(module
;; CHECK: (type $struct (shared (struct (field (ref null (shared waitqueue))))))
(type $struct (shared (struct (field (ref null (shared waitqueue))))))

;; CHECK: (func $flows-null (type $1) (result (ref null (shared waitqueue)))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $helper
;; CHECK-NEXT: (ref.null (shared nowaitqueue))
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.null (shared nowaitqueue))
;; CHECK-NEXT: )
(func $flows-null (export "test") (result (ref null (shared waitqueue)))
;; GUFA can figure out that this function always returns null
;; even though it flows through a struct.
(call $helper (ref.null (shared nowaitqueue)))
)

;; CHECK: (func $helper (type $2) (param $w (ref null (shared waitqueue))) (result (ref null (shared waitqueue)))
;; CHECK-NEXT: (local $s (ref null $struct))
;; CHECK-NEXT: (local.set $s
;; CHECK-NEXT: (struct.new $struct
;; CHECK-NEXT: (ref.null (shared nowaitqueue))
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block (result (ref null (shared nowaitqueue)))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (struct.get $struct 0
;; CHECK-NEXT: (local.get $s)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.null (shared nowaitqueue))
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (ref.null (shared nowaitqueue))
;; CHECK-NEXT: )
(func $helper (param $w (ref null (shared waitqueue))) (result (ref null (shared waitqueue)))
(local $s (ref null $struct))
(local.set $s (struct.new $struct (local.get $w)))
(struct.get $struct 0 (local.get $s))
)
)
Loading