Skip to content

Commit de525af

Browse files
authored
extract common code to create a dummy IRCode into a utility function (#52329)
Simplifies test code. xref: <#52323 (review)>.
1 parent 68b4587 commit de525af

File tree

4 files changed

+119
-176
lines changed

4 files changed

+119
-176
lines changed

test/compiler/interpreter_exec.jl

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
# tests that interpreter matches codegen
44
using Test
5-
using Core: GotoIfNot, ReturnNode
5+
using Core.IR
66

77
# test that interpreter correctly handles PhiNodes (#29262)
88
let m = Meta.@lower 1 + 1
99
@assert Meta.isexpr(m, :thunk)
10-
src = m.args[1]::Core.CodeInfo
10+
src = m.args[1]::CodeInfo
1111
src.code = Any[
1212
# block 1
1313
QuoteNode(:a),
1414
QuoteNode(:b),
1515
GlobalRef(@__MODULE__, :test29262),
16-
GotoIfNot(Core.SSAValue(3), 6),
16+
GotoIfNot(SSAValue(3), 6),
1717
# block 2
18-
Core.PhiNode(Int32[4], Any[Core.SSAValue(1)]),
19-
Core.PhiNode(Int32[4, 5], Any[Core.SSAValue(2), Core.SSAValue(5)]),
20-
ReturnNode(Core.SSAValue(6)),
18+
PhiNode(Int32[4], Any[SSAValue(1)]),
19+
PhiNode(Int32[4, 5], Any[SSAValue(2), SSAValue(5)]),
20+
ReturnNode(SSAValue(6)),
2121
]
2222
nstmts = length(src.code)
2323
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]
@@ -33,32 +33,32 @@ end
3333

3434
let m = Meta.@lower 1 + 1
3535
@assert Meta.isexpr(m, :thunk)
36-
src = m.args[1]::Core.CodeInfo
36+
src = m.args[1]::CodeInfo
3737
src.code = Any[
3838
# block 1
3939
QuoteNode(:a),
4040
QuoteNode(:b),
4141
QuoteNode(:c),
4242
GlobalRef(@__MODULE__, :test29262),
4343
# block 2
44-
Core.PhiNode(Int32[4, 16], Any[false, true]), # false, true
45-
Core.PhiNode(Int32[4, 16], Any[Core.SSAValue(1), Core.SSAValue(2)]), # :a, :b
46-
Core.PhiNode(Int32[4, 16], Any[Core.SSAValue(3), Core.SSAValue(6)]), # :c, :a
47-
Core.PhiNode(Int32[16], Any[Core.SSAValue(7)]), # NULL, :c
44+
PhiNode(Int32[4, 16], Any[false, true]), # false, true
45+
PhiNode(Int32[4, 16], Any[SSAValue(1), SSAValue(2)]), # :a, :b
46+
PhiNode(Int32[4, 16], Any[SSAValue(3), SSAValue(6)]), # :c, :a
47+
PhiNode(Int32[16], Any[SSAValue(7)]), # NULL, :c
4848
# block 3
49-
Core.PhiNode(Int32[], Any[]), # NULL, NULL
50-
Core.PhiNode(Int32[17, 8], Any[true, Core.SSAValue(4)]), # test29262, test29262, [true]
51-
Core.PhiNode(Int32[17], Vector{Any}(undef, 1)), # NULL, NULL
52-
Core.PhiNode(Int32[8], Vector{Any}(undef, 1)), # NULL, NULL
53-
Core.PhiNode(Int32[], Any[]), # NULL, NULL
54-
Core.PhiNode(Int32[17, 8], Any[Core.SSAValue(2), Core.SSAValue(8)]), # NULL, :c, [:b]
55-
Core.PhiNode(Int32[], Any[]), # NULL, NULL
56-
GotoIfNot(Core.SSAValue(5), 5),
49+
PhiNode(Int32[], Any[]), # NULL, NULL
50+
PhiNode(Int32[17, 8], Any[true, SSAValue(4)]), # test29262, test29262, [true]
51+
PhiNode(Int32[17], Vector{Any}(undef, 1)), # NULL, NULL
52+
PhiNode(Int32[8], Vector{Any}(undef, 1)), # NULL, NULL
53+
PhiNode(Int32[], Any[]), # NULL, NULL
54+
PhiNode(Int32[17, 8], Any[SSAValue(2), SSAValue(8)]), # NULL, :c, [:b]
55+
PhiNode(Int32[], Any[]), # NULL, NULL
56+
GotoIfNot(SSAValue(5), 5),
5757
# block 4
58-
GotoIfNot(Core.SSAValue(10), 9),
58+
GotoIfNot(SSAValue(10), 9),
5959
# block 5
60-
Expr(:call, GlobalRef(Core, :tuple), Core.SSAValue(6), Core.SSAValue(7), Core.SSAValue(8), Core.SSAValue(14)),
61-
ReturnNode(Core.SSAValue(18)),
60+
Expr(:call, GlobalRef(Core, :tuple), SSAValue(6), SSAValue(7), SSAValue(8), SSAValue(14)),
61+
ReturnNode(SSAValue(18)),
6262
]
6363
nstmts = length(src.code)
6464
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]
@@ -74,28 +74,28 @@ end
7474

7575
let m = Meta.@lower 1 + 1
7676
@assert Meta.isexpr(m, :thunk)
77-
src = m.args[1]::Core.CodeInfo
77+
src = m.args[1]::CodeInfo
7878
src.code = Any[
7979
# block 1
8080
QuoteNode(:a),
8181
QuoteNode(:b),
8282
GlobalRef(@__MODULE__, :test29262),
8383
# block 2
84-
Core.EnterNode(11),
84+
EnterNode(11),
8585
# block 3
86-
Core.UpsilonNode(),
87-
Core.UpsilonNode(),
88-
Core.UpsilonNode(Core.SSAValue(2)),
89-
GotoIfNot(Core.SSAValue(3), 10),
86+
UpsilonNode(),
87+
UpsilonNode(),
88+
UpsilonNode(SSAValue(2)),
89+
GotoIfNot(SSAValue(3), 10),
9090
# block 4
91-
Core.UpsilonNode(Core.SSAValue(1)),
91+
UpsilonNode(SSAValue(1)),
9292
# block 5
9393
Expr(:throw_undef_if_not, :expected, false),
9494
# block 6
95-
Core.PhiCNode(Any[Core.SSAValue(5), Core.SSAValue(7), Core.SSAValue(9)]), # NULL, :a, :b
96-
Core.PhiCNode(Any[Core.SSAValue(6)]), # NULL
95+
PhiCNode(Any[SSAValue(5), SSAValue(7), SSAValue(9)]), # NULL, :a, :b
96+
PhiCNode(Any[SSAValue(6)]), # NULL
9797
# block 7
98-
ReturnNode(Core.SSAValue(11)),
98+
ReturnNode(SSAValue(11)),
9999
]
100100
nstmts = length(src.code)
101101
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]

0 commit comments

Comments
 (0)