Skip to content

Commit b8243b3

Browse files
committed
Fix interpreter_exec.jl test
This test was supposed to check that we correctly handled PhiNodes in uninferred code in both the interpreter and the compiler. However, the compiler path wasn't actually exercised, because the `inferred=true` part of this forced it to be skipped. Drop that and fix the exposed issues in the compiler where we didn't handle PhiNodes properly.
1 parent a26bd7f commit b8243b3

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,10 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
33043304
end
33053305
if rt === Bottom
33063306
ssavaluetypes[currpc] = Bottom
3307+
# Special case: Union typed PhiNodes do not error (but must also be unused)
3308+
if isa(stmt, PhiNode)
3309+
continue
3310+
end
33073311
@goto find_next_bb
33083312
end
33093313
if changes !== nothing

base/compiler/optimize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
10851085
idx += 1
10861086
prevloc = codeloc
10871087
end
1088-
if ssavaluetypes[idx] === Union{} && !(oldidx in sv.unreachable)
1088+
if ssavaluetypes[idx] === Union{} && !(oldidx in sv.unreachable) && !isa(code[idx], PhiNode)
10891089
# We should have converted any must-throw terminators to an equivalent w/o control-flow edges
10901090
@assert !isterminator(code[idx])
10911091

test/compiler/interpreter_exec.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ let m = Meta.@lower 1 + 1
2020
ReturnNode(SSAValue(6)),
2121
]
2222
nstmts = length(src.code)
23-
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]
23+
src.ssavaluetypes = nstmts
2424
src.ssaflags = fill(UInt8(0x00), nstmts)
2525
src.codelocs = fill(Int32(1), nstmts)
26-
src.inferred = true
2726
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
2827
global test29262 = true
2928
@test :a === @eval $m
@@ -61,13 +60,13 @@ let m = Meta.@lower 1 + 1
6160
ReturnNode(SSAValue(18)),
6261
]
6362
nstmts = length(src.code)
64-
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]
63+
src.ssavaluetypes = nstmts
6564
src.ssaflags = fill(UInt8(0x00), nstmts)
6665
src.codelocs = fill(Int32(1), nstmts)
67-
src.inferred = true
6866
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
6967
global test29262 = true
7068
@test (:b, :a, :c, :c) === @eval $m
69+
src.ssavaluetypes = nstmts
7170
global test29262 = false
7271
@test (:b, :a, :c, :b) === @eval $m
7372
end
@@ -98,10 +97,9 @@ let m = Meta.@lower 1 + 1
9897
ReturnNode(SSAValue(11)),
9998
]
10099
nstmts = length(src.code)
101-
src.ssavaluetypes = Any[ Any for _ = 1:nstmts ]
100+
src.ssavaluetypes = nstmts
102101
src.ssaflags = fill(UInt8(0x00), nstmts)
103102
src.codelocs = fill(Int32(1), nstmts)
104-
src.inferred = true
105103
Core.Compiler.verify_ir(Core.Compiler.inflate_ir(src))
106104
global test29262 = true
107105
@test :a === @eval $m

0 commit comments

Comments
 (0)