File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 125125 'minimize-rec-groups-desc.wast' ,
126126 'precompute-desc.wast' ,
127127 'gc-desc.wast' ,
128+ 'simplify-locals-desc.wast' ,
128129 # TODO: fix split_wast() on tricky escaping situations like a string ending
129130 # in \\" (the " is not escaped - there is an escaped \ before it)
130131 'string-lifting-section.wast' ,
Original file line number Diff line number Diff line change @@ -858,7 +858,16 @@ class EffectAnalyzer {
858858 parent.implicitTrap = true ;
859859 }
860860 void visitBrOn (BrOn* curr) { parent.breakTargets .insert (curr->name ); }
861- void visitStructNew (StructNew* curr) {}
861+ void visitStructNew (StructNew* curr) {
862+ if (curr->desc ) {
863+ // Traps when the descriptor is null.
864+ if (curr->desc ->type .isNull ()) {
865+ parent.trap = true ;
866+ } else if (curr->desc ->type .isNullable ()) {
867+ parent.implicitTrap = true ;
868+ }
869+ }
870+ }
862871 void visitStructGet (StructGet* curr) {
863872 if (curr->ref ->type == Type::unreachable) {
864873 return ;
Original file line number Diff line number Diff line change 1+ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2+
3+ ;; RUN: wasm-opt %s --simplify-locals -all -S -o - | filecheck %s
4+
5+ (module
6+ (rec
7+ ;; CHECK: (rec
8+ ;; CHECK-NEXT: (type $struct (descriptor $desc (struct)))
9+ (type $struct (descriptor $desc (struct )))
10+ ;; CHECK: (type $desc (sub (describes $struct (struct))))
11+ (type $desc (sub (describes $struct (struct ))))
12+ )
13+
14+ ;; CHECK: (func $test (type $2)
15+ ;; CHECK-NEXT: (local $l (ref null $struct))
16+ ;; CHECK-NEXT: (drop
17+ ;; CHECK-NEXT: (struct.new_default $struct
18+ ;; CHECK-NEXT: (ref.null none)
19+ ;; CHECK-NEXT: )
20+ ;; CHECK-NEXT: )
21+ ;; CHECK-NEXT: )
22+ (func $test (export " test" )
23+ (local $l (ref null $struct ))
24+ (local.set $l
25+ ;; We should preserve this trap.
26+ (struct.new_default $struct
27+ (ref.null none)
28+ )
29+ )
30+ )
31+ )
You can’t perform that action at this time.
0 commit comments