Skip to content

Commit

Permalink
Don't bailout on no-value phinodes to fix illegal instruction problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Atol committed Jul 22, 2022
1 parent bed999e commit 44ef0de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
16 changes: 0 additions & 16 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,11 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
if seen != napplicable
# there may be unanalyzed effects within unseen dispatch candidate,
# but we can still ignore nonoverlayed effect here since we already accounted for it
<<<<<<< HEAD
all_effects = tristate_merge(all_effects, EFFECTS_UNKNOWN)
elseif isa(matches, MethodMatches) ? (!matches.fullmatch || any_ambig(matches)) :
(!all(matches.fullmatches) || any_ambig(matches))
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
all_effects = Effects(all_effects; nothrow=ALWAYS_FALSE)
=======
all_effects = EFFECTS_UNKNOWN
elseif isa(matches, MethodMatches) ? (!matches.fullmatch || any_ambig(matches)) :
(!_all(b->b, matches.fullmatches) || any_ambig(matches))
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
all_effects = Effects(all_effects, nothrow=TRISTATE_UNKNOWN)
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)
end

rettype = from_interprocedural!(rettype, sv, arginfo, conditionals)
Expand All @@ -252,11 +244,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
delete!(sv.pclimitations, caller)
end
end
<<<<<<< HEAD
return CallMeta(rettype, all_effects, info)
=======
return CallMeta(rettype, info, all_effects)
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)
end

struct FailedMethodMatch
Expand Down Expand Up @@ -836,11 +824,7 @@ function concrete_eval_call(interp::AbstractInterpreter,
Core._call_in_world_total(world, f, args...)
catch
# The evaulation threw. By :consistent-cy, we're guaranteed this would have happened at runtime
<<<<<<< HEAD
return ConstCallResults(Union{}, ConcreteResult(result.edge::MethodInstance, result.effects), result.effects)
=======
return ConstCallResults(Union{}, ConcreteResult(result.edge, result.edge_effects), result.edge_effects)
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)
end
if is_inlineable_constant(value) || call_result_unused(sv)
# If the constant is not inlineable, still do the const-prop, since the
Expand Down
20 changes: 5 additions & 15 deletions base/compiler/ssair/irinterp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function reprocess_instruction!(interp::AbstractInterpreter, ir::IRCode, mi::Met
mi_cache, sv::InferenceState,
tpdum::TwoPhaseDefUseMap, idx::Int, bb::Union{Int, Nothing},
@nospecialize(inst), @nospecialize(typ),
phi_revisit, mi::MethodInstance)
phi_revisit)
function update_phi!(from, to)
if length(ir.cfg.blocks[to].preds) == 0
return
Expand Down Expand Up @@ -315,13 +315,8 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache
any_refined = true
delete!(ssa_refined, idx)
end
<<<<<<< HEAD
if any_refined && reprocess_instruction!(interp, ir, mi, mi_cache,
frame, tpdum, idx, bb, inst, typ, ssa_refined)
=======
if any_refined && reprocess_instruction!(interp, ir, mi_cache,
frame, tpdum, idx, bb, inst, typ, ssa_refined, mi)
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)
push!(ssa_refined, idx)
end
if idx == lstmt && process_terminator!(ip, bb, idx)
Expand All @@ -343,7 +338,6 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache
lstmt = last(stmts)
for idx = stmts
inst = ir.stmts[idx][:inst]
typ = ir.stmts[idx][:type]
for ur in userefs(inst)
val = ur[]
if isa(val, Argument)
Expand All @@ -367,7 +361,6 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache
lstmt = last(stmts)
for idx = stmts
inst = ir.stmts[idx][:inst]
typ = ir.stmts[idx][:type]
for ur in userefs(inst)
val = ur[]
if isa(val, SSAValue)
Expand All @@ -389,13 +382,8 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache
idx = popfirst!(stmt_ip)
inst = ir.stmts[idx][:inst]
typ = ir.stmts[idx][:type]
<<<<<<< HEAD
if reprocess_instruction!(interp, ir, mi, mi_cache, frame,
tpdum, idx, nothing, inst, typ, ssa_refined)
=======
if reprocess_instruction!(interp, ir, mi_cache, frame,
tpdum, idx, nothing, inst, typ, ssa_refined, mi)
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)
append!(stmt_ip, tpdum[idx])
end
end
Expand All @@ -409,7 +397,8 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache
continue
end
inst = ir.stmts[idx][:inst]
ultimate_rt = tmerge(ultimate_rt, argextype(inst.val, ir))
rt = argextype(inst.val, ir)
ultimate_rt = tmerge(ultimate_rt, rt)
end
return ultimate_rt
end
Expand All @@ -423,6 +412,7 @@ function ir_abstract_constant_propagation(interp::AbstractInterpreter, mi_cache,
Timings.exit_current_timer(inf_frame)
return v
else
return _ir_abstract_constant_propagation(interp, mi_cache, frame, mi, ir, argtypes)
T = _ir_abstract_constant_propagation(interp, mi_cache, frame, mi, ir, argtypes)
return T
end
end
5 changes: 0 additions & 5 deletions base/compiler/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ struct SemiConcreteResult
ir::IRCode
effects::Effects
end
<<<<<<< HEAD
=======

const ConstResult = Union{ConstPropResult,ConcreteResult, SemiConcreteResult}
>>>>>>> 983f70db2c (Handle foreigncall in irinterp, fix abstract_invoke inf loop)

const ConstResult = Union{ConstPropResult,ConcreteResult, SemiConcreteResult}
"""
Expand Down

0 comments on commit 44ef0de

Please sign in to comment.