Skip to content

Commit a941846

Browse files
authored
[NFC] Add the type of the Expression when eliding it (#6362)
In some cases we don't print an Expression in full if it is unreachable, so we print something instead as a placeholder. This happens in unreachable code when the children don't provide enough info to print the parent (e.g. a StructGet with an unreachable reference doesn't know what struct type to use). This PR prints out the name of the Expression type of such things, which can help debugging sometimes.
1 parent ac62d28 commit a941846

30 files changed

Lines changed: 69 additions & 68 deletions

src/passes/Print.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,8 @@ void PrintSExpression::maybePrintUnreachableReplacement(Expression* curr,
27862786
// Emit a block with drops of the children.
27872787
o << "(block";
27882788
if (!minify) {
2789-
o << " ;; (replaces something unreachable we can't emit)";
2789+
o << " ;; (replaces unreachable " << getExpressionName(curr)
2790+
<< " we can't emit)";
27902791
}
27912792
incIndent();
27922793
for (auto* child : ChildIterator(curr)) {

test/lit/passes/cfp.wast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,22 +508,22 @@
508508

509509
;; CHECK: (func $test (type $0)
510510
;; CHECK-NEXT: (drop
511-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
511+
;; CHECK-NEXT: (block ;; (replaces unreachable StructNew we can't emit)
512512
;; CHECK-NEXT: (drop
513513
;; CHECK-NEXT: (unreachable)
514514
;; CHECK-NEXT: )
515515
;; CHECK-NEXT: (unreachable)
516516
;; CHECK-NEXT: )
517517
;; CHECK-NEXT: )
518518
;; CHECK-NEXT: (drop
519-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
519+
;; CHECK-NEXT: (block ;; (replaces unreachable StructGet we can't emit)
520520
;; CHECK-NEXT: (drop
521521
;; CHECK-NEXT: (unreachable)
522522
;; CHECK-NEXT: )
523523
;; CHECK-NEXT: (unreachable)
524524
;; CHECK-NEXT: )
525525
;; CHECK-NEXT: )
526-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
526+
;; CHECK-NEXT: (block ;; (replaces unreachable StructSet we can't emit)
527527
;; CHECK-NEXT: (drop
528528
;; CHECK-NEXT: (unreachable)
529529
;; CHECK-NEXT: )

test/lit/passes/dae-gc-refine-return.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@
472472
(return_call_ref $"return_{}" (local.get $"return_{}"))
473473
)
474474
;; CHECK: (func $tail-caller-call_ref-unreachable (type $2) (result anyref)
475-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
475+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
476476
;; CHECK-NEXT: (drop
477477
;; CHECK-NEXT: (unreachable)
478478
;; CHECK-NEXT: )

test/lit/passes/dae_all-features.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@
699699
;; CHECK: (type $1 (func))
700700

701701
;; CHECK: (func $no-caller (type $A) (result (ref $A))
702-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
702+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
703703
;; CHECK-NEXT: (drop
704704
;; CHECK-NEXT: (ref.null nofunc)
705705
;; CHECK-NEXT: )

test/lit/passes/gsi.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@
12081208
))
12091209

12101210
;; CHECK: (func $func (type $1) (param $ref (ref null $A)) (result i32)
1211-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
1211+
;; CHECK-NEXT: (block ;; (replaces unreachable StructGet we can't emit)
12121212
;; CHECK-NEXT: (drop
12131213
;; CHECK-NEXT: (ref.null none)
12141214
;; CHECK-NEXT: )

test/lit/passes/gto-removals.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560

561561
;; CHECK: (func $new-unreachable (type $4)
562562
;; CHECK-NEXT: (drop
563-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
563+
;; CHECK-NEXT: (block ;; (replaces unreachable StructNew we can't emit)
564564
;; CHECK-NEXT: (drop
565565
;; CHECK-NEXT: (i32.const 2)
566566
;; CHECK-NEXT: )

test/lit/passes/gufa-extern.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
;; CHECK: (func $non-exported (type $0) (param $ext externref) (param $any anyref)
4141
;; CHECK-NEXT: (drop
42-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
42+
;; CHECK-NEXT: (block ;; (replaces unreachable RefCast we can't emit)
4343
;; CHECK-NEXT: (drop
4444
;; CHECK-NEXT: (extern.internalize
4545
;; CHECK-NEXT: (unreachable)

test/lit/passes/gufa-refs.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4567,7 +4567,7 @@
45674567
)
45684568

45694569
;; CHECK: (func $call_ref-nofunc (type $2)
4570-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
4570+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
45714571
;; CHECK-NEXT: (drop
45724572
;; CHECK-NEXT: (i32.const 1)
45734573
;; CHECK-NEXT: )

test/lit/passes/gufa-tnh-closed.wast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
)
3939

4040
;; CHECK: (func $caller (type $2) (param $x funcref)
41-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
41+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
4242
;; CHECK-NEXT: (drop
4343
;; CHECK-NEXT: (unreachable)
4444
;; CHECK-NEXT: )
@@ -83,7 +83,7 @@
8383
)
8484

8585
;; CHECK: (func $caller (type $0) (param $x funcref)
86-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
86+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
8787
;; CHECK-NEXT: (drop
8888
;; CHECK-NEXT: (unreachable)
8989
;; CHECK-NEXT: )
@@ -496,7 +496,7 @@
496496
;; CHECK-NEXT: (local.get $func3)
497497
;; CHECK-NEXT: )
498498
;; CHECK-NEXT: )
499-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
499+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
500500
;; CHECK-NEXT: (drop
501501
;; CHECK-NEXT: (struct.new_default $Y2)
502502
;; CHECK-NEXT: )

test/lit/passes/gufa-vs-cfp.wast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@
459459

460460
;; CHECK: (func $test (type $0)
461461
;; CHECK-NEXT: (drop
462-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
462+
;; CHECK-NEXT: (block ;; (replaces unreachable StructNew we can't emit)
463463
;; CHECK-NEXT: (drop
464464
;; CHECK-NEXT: (i32.const 10)
465465
;; CHECK-NEXT: )
@@ -469,9 +469,9 @@
469469
;; CHECK-NEXT: (unreachable)
470470
;; CHECK-NEXT: )
471471
;; CHECK-NEXT: )
472-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
472+
;; CHECK-NEXT: (block ;; (replaces unreachable StructSet we can't emit)
473473
;; CHECK-NEXT: (drop
474-
;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit)
474+
;; CHECK-NEXT: (block ;; (replaces unreachable StructGet we can't emit)
475475
;; CHECK-NEXT: (drop
476476
;; CHECK-NEXT: (unreachable)
477477
;; CHECK-NEXT: )

0 commit comments

Comments
 (0)