Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
work
  • Loading branch information
kripken committed Apr 8, 2024
commit 17ad3ffb51b8e7a585e2bfbec69f111daca86438
2 changes: 1 addition & 1 deletion src/passes/OptimizeInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ struct OptimizeInstructions
}
}

void zvisitStructNew(StructNew* curr) {
void visitStructNew(StructNew* curr) {
// If values are provided, but they are all the default, then we can remove
// them (in reachable code).
if (curr->type == Type::unreachable || curr->isWithDefault()) {
Expand Down
19 changes: 11 additions & 8 deletions test/lit/passes/optimize-instructions-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3174,23 +3174,26 @@
)
)

;; CHECK: (func $struct.new_with_default (type $5)
;; CHECK: (func $struct.new (type $5)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (struct.new $struct
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (block (result i32)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (block (result (ref $struct))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block (result i32)
;; CHECK-NEXT: (call $struct.new)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i64.const 0)
;; CHECK-NEXT: (struct.new_default $struct)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $struct.new_with_default
(func $struct.new
(drop
(struct.new $struct
(i32.const 0)
(block (result i32)
;; A block in the middle, even with side effects, is no problem.
(call $struct.new)
(i32.const 0)
)
(i32.const 0)
Expand Down