Skip to content

Commit d9c6d61

Browse files
committed
[test] Print HIR before leaving SSA
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react-forget/pull/812). * __->__ #812 [test] Print HIR before leaving SSA Looking at the HIR before it leaves SSA helps debugging better.
1 parent 1f4705b commit d9c6d61

File tree

60 files changed

+1144
-1103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1144
-1103
lines changed

compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,30 @@ function mutate(x, y) {}
2727

2828
```
2929
bb0:
30-
[1] Let mutate a$2_@0[0:12] = Object { }
31-
[2] Let mutate b$3_@0[0:11] = Object { }
32-
[3] Let mutate c$4_@0[0:11] = Object { }
30+
[1] Let mutate a$8_@0[0:12] = Object { }
31+
[2] Let mutate b$9_@0[0:11] = Object { }
32+
[3] Let mutate c$10_@0[0:11] = Object { }
3333
[4] While test=bb1 loop=bb3 fallthrough=bb2
3434
bb1:
3535
predecessor blocks: bb0 bb3
36-
[5] If (read cond$1) then:bb3 else:bb2
36+
a$12_@0[0:11]: phi(bb0: a$8_@0, bb3: a$15_@0)
37+
b$14_@0[0:11]: phi(bb0: b$9_@0, bb3: b$17_@0)
38+
c$16_@0[0:11]: phi(bb0: c$10_@0, bb3: c$18_@0)
39+
[5] If (read cond$7) then:bb3 else:bb2
3740
bb3:
3841
predecessor blocks: bb1
39-
[6] Let mutate z$5_@0[0:11] = read a$2_@0
40-
[7] Reassign mutate a$2_@0[0:11] = read b$3_@0
41-
[8] Reassign mutate b$3_@0[0:11] = read c$4_@0
42-
[9] Reassign mutate c$4_@0[0:11] = read z$5_@0
43-
[10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
42+
[6] Let mutate z$13_@0[0:11] = read a$12_@0
43+
[7] Reassign mutate a$15_@0[0:11] = read b$14_@0
44+
[8] Reassign mutate b$17_@0[0:11] = read c$16_@0
45+
[9] Reassign mutate c$18_@0[0:11] = read z$13_@0
46+
[10] Call mutate mutate$6_@0(mutate a$15_@0, mutate b$17_@0)
4447
[11] Goto(Continue) bb1
4548
bb2:
4649
predecessor blocks: bb1
47-
[12] read a$2_@0
48-
[13] read b$3_@0
49-
[14] read c$4_@0
50-
[15] Return freeze a$2_@0
50+
[12] read a$12_@0
51+
[13] read b$14_@0
52+
[14] read c$16_@0
53+
[15] Return freeze a$12_@0
5154
```
5255

5356
### CFG
@@ -57,32 +60,32 @@ flowchart TB
5760
%% Basic Blocks
5861
subgraph bb0
5962
bb0_instrs["
60-
[1] Let mutate a$2_@0[0:12] = Object { }
61-
[2] Let mutate b$3_@0[0:11] = Object { }
62-
[3] Let mutate c$4_@0[0:11] = Object { }
63+
[1] Let mutate a$8_@0[0:12] = Object { }
64+
[2] Let mutate b$9_@0[0:11] = Object { }
65+
[3] Let mutate c$10_@0[0:11] = Object { }
6366
"]
6467
bb0_instrs --> bb0_terminal(["While"])
6568
end
6669
subgraph bb1
67-
bb1_terminal(["If (read cond$1)"])
70+
bb1_terminal(["If (read cond$7)"])
6871
end
6972
subgraph bb3
7073
bb3_instrs["
71-
[6] Let mutate z$5_@0[0:11] = read a$2_@0
72-
[7] Reassign mutate a$2_@0[0:11] = read b$3_@0
73-
[8] Reassign mutate b$3_@0[0:11] = read c$4_@0
74-
[9] Reassign mutate c$4_@0[0:11] = read z$5_@0
75-
[10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
74+
[6] Let mutate z$13_@0[0:11] = read a$12_@0
75+
[7] Reassign mutate a$15_@0[0:11] = read b$14_@0
76+
[8] Reassign mutate b$17_@0[0:11] = read c$16_@0
77+
[9] Reassign mutate c$18_@0[0:11] = read z$13_@0
78+
[10] Call mutate mutate$6_@0(mutate a$15_@0, mutate b$17_@0)
7679
"]
7780
bb3_instrs --> bb3_terminal(["Goto"])
7881
end
7982
subgraph bb2
8083
bb2_instrs["
81-
[12] read a$2_@0
82-
[13] read b$3_@0
83-
[14] read c$4_@0
84+
[12] read a$12_@0
85+
[13] read b$14_@0
86+
[14] read c$16_@0
8487
"]
85-
bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"])
88+
bb2_instrs --> bb2_terminal(["Return freeze a$12_@0"])
8689
end
8790
8891
%% Jumps

compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function g(a) {
2020

2121
```
2222
bb0:
23-
[1] Let mutate x$1_@0 = 1
24-
[2] Const mutate $2_@1 = 1
25-
[3] Reassign mutate x$1_@2 = Binary read x$1_@0 + read $2_@1
26-
[4] Const mutate $3_@3 = 1
27-
[5] Reassign mutate x$1_@4 = Binary read x$1_@2 + read $3_@3
28-
[6] Const mutate $4_@5 = 1
29-
[7] Reassign mutate x$1_@6 = Binary read x$1_@4 >>> read $4_@5
23+
[1] Let mutate x$5_@0 = 1
24+
[2] Const mutate $6_@1 = 1
25+
[3] Reassign mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
26+
[4] Const mutate $8_@3 = 1
27+
[5] Reassign mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
28+
[6] Const mutate $10_@5 = 1
29+
[7] Reassign mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
3030
[8] Return
3131
```
3232

@@ -37,13 +37,13 @@ flowchart TB
3737
%% Basic Blocks
3838
subgraph bb0
3939
bb0_instrs["
40-
[1] Let mutate x$1_@0 = 1
41-
[2] Const mutate $2_@1 = 1
42-
[3] Reassign mutate x$1_@2 = Binary read x$1_@0 + read $2_@1
43-
[4] Const mutate $3_@3 = 1
44-
[5] Reassign mutate x$1_@4 = Binary read x$1_@2 + read $3_@3
45-
[6] Const mutate $4_@5 = 1
46-
[7] Reassign mutate x$1_@6 = Binary read x$1_@4 >>> read $4_@5
40+
[1] Let mutate x$5_@0 = 1
41+
[2] Const mutate $6_@1 = 1
42+
[3] Reassign mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
43+
[4] Const mutate $8_@3 = 1
44+
[5] Reassign mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
45+
[6] Const mutate $10_@5 = 1
46+
[7] Reassign mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
4747
"]
4848
bb0_instrs --> bb0_terminal(["Return"])
4949
end
@@ -67,10 +67,10 @@ function f$0() {
6767

6868
```
6969
bb0:
70-
[1] Const mutate $2_@0 = 1
71-
[2] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c + read $2_@0
72-
[3] Const mutate $3_@2 = 2
73-
[4] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c * read $3_@2
70+
[1] Const mutate $5_@0 = 1
71+
[2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
72+
[3] Const mutate $6_@2 = 2
73+
[4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
7474
[5] Return
7575
```
7676

@@ -81,10 +81,10 @@ flowchart TB
8181
%% Basic Blocks
8282
subgraph bb0
8383
bb0_instrs["
84-
[1] Const mutate $2_@0 = 1
85-
[2] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c + read $2_@0
86-
[3] Const mutate $3_@2 = 2
87-
[4] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c * read $3_@2
84+
[1] Const mutate $5_@0 = 1
85+
[2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
86+
[3] Const mutate $6_@2 = 2
87+
[4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
8888
"]
8989
bb0_instrs --> bb0_terminal(["Return"])
9090
end

compiler/forget/src/__tests__/fixtures/hir/call.expect.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ function foo$0() {}
4545

4646
```
4747
bb0:
48-
[1] Const mutate a$2_@0[0:7] = Array []
49-
[2] Const mutate b$3_@0[0:7] = Object { }
50-
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
51-
[4] Const mutate $6_@1 = "div"
52-
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
53-
[6] Call mutate foo$4_@0(mutate b$3_@0)
54-
[7] Const mutate $7_@3 = "div"
55-
[8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
56-
[9] Return read $8_@4
48+
[1] Const mutate a$10_@0[0:7] = Array []
49+
[2] Const mutate b$11_@0[0:7] = Object { }
50+
[3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
51+
[4] Const mutate $12_@1 = "div"
52+
[5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
53+
[6] Call mutate foo$4_@0(mutate b$11_@0)
54+
[7] Const mutate $14_@3 = "div"
55+
[8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
56+
[9] Return read $15_@4
5757
```
5858

5959
### CFG
@@ -63,16 +63,16 @@ flowchart TB
6363
%% Basic Blocks
6464
subgraph bb0
6565
bb0_instrs["
66-
[1] Const mutate a$2_@0[0:7] = Array []
67-
[2] Const mutate b$3_@0[0:7] = Object { }
68-
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
69-
[4] Const mutate $6_@1 = 'div'
70-
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
71-
[6] Call mutate foo$4_@0(mutate b$3_@0)
72-
[7] Const mutate $7_@3 = 'div'
73-
[8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
66+
[1] Const mutate a$10_@0[0:7] = Array []
67+
[2] Const mutate b$11_@0[0:7] = Object { }
68+
[3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
69+
[4] Const mutate $12_@1 = 'div'
70+
[5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
71+
[6] Call mutate foo$4_@0(mutate b$11_@0)
72+
[7] Const mutate $14_@3 = 'div'
73+
[8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
7474
"]
75-
bb0_instrs --> bb0_terminal(["Return read $8_@4"])
75+
bb0_instrs --> bb0_terminal(["Return read $15_@4"])
7676
end
7777
7878
%% Jumps

compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ function foo(a, b, c) {
1818

1919
```
2020
bb0:
21-
[1] If (read a$1) then:bb3 else:bb1
21+
[1] If (read a$4) then:bb3 else:bb1
2222
bb3:
2323
predecessor blocks: bb0
2424
[2] While test=bb4 loop=bb6 fallthrough=bb1
2525
bb4:
2626
predecessor blocks: bb3 bb7
27-
[3] If (read b$2) then:bb6 else:bb1
27+
[3] If (read b$5) then:bb6 else:bb1
2828
bb6:
2929
predecessor blocks: bb4
30-
[4] If (read c$3) then:bb1 else:bb7
30+
[4] If (read c$6) then:bb1 else:bb7
3131
bb7:
3232
predecessor blocks: bb6
3333
[5] Goto(Continue) bb4
@@ -42,16 +42,16 @@ bb1:
4242
flowchart TB
4343
%% Basic Blocks
4444
subgraph bb0
45-
bb0_terminal(["If (read a$1)"])
45+
bb0_terminal(["If (read a$4)"])
4646
end
4747
subgraph bb3
4848
bb3_terminal(["While"])
4949
end
5050
subgraph bb4
51-
bb4_terminal(["If (read b$2)"])
51+
bb4_terminal(["If (read b$5)"])
5252
end
5353
subgraph bb6
54-
bb6_terminal(["If (read c$3)"])
54+
bb6_terminal(["If (read c$6)"])
5555
end
5656
subgraph bb7
5757
bb7_terminal(["Goto"])

0 commit comments

Comments
 (0)