Skip to content

Commit

Permalink
add missing type annotations from #50805
Browse files Browse the repository at this point in the history
Also adds some cosmetic changes.
  • Loading branch information
aviatesk committed Sep 8, 2023
1 parent 253f2e9 commit a32ce71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
14 changes: 7 additions & 7 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function ipo_dataflow_analysis!(interp::AbstractInterpreter, ir::IRCode, result:
bstmt = ir[barg][:stmt]
isexpr(bstmt, :boundscheck) || return false
# If IR_FLAG_INBOUNDS is already set, no more conditional ub
(length(bstmt.args) != 0 && bstmt.args[1] === false) && return false
(!isempty(bstmt.args) && bstmt.args[1] === false) && return false
any_conditional_ub = true
return true
end
Expand All @@ -576,10 +576,10 @@ function ipo_dataflow_analysis!(interp::AbstractInterpreter, ir::IRCode, result:
# ignore control flow node – they are not removable on their own and thus not
# have `IR_FLAG_EFFECT_FREE` but still do not taint `:effect_free`-ness of
# the whole method invocation
all_effect_free &= (flag & IR_FLAG_EFFECT_FREE) != 0
all_effect_free &= !iszero(flag & IR_FLAG_EFFECT_FREE)
end
all_nothrow &= (flag & IR_FLAG_NOTHROW) != 0
if (flag & IR_FLAG_NOUB) == 0
all_nothrow &= !iszero(flag & IR_FLAG_NOTHROW)
if iszero(flag & IR_FLAG_NOUB)
if !is_conditional_noub(inst)
all_noub = false
end
Expand All @@ -588,7 +588,7 @@ function ipo_dataflow_analysis!(interp::AbstractInterpreter, ir::IRCode, result:

function scan_inconsistency!(inst::Instruction, idx::Int)
flag = inst[:flag]
stmt_inconsistent = (flag & IR_FLAG_CONSISTENT) == 0
stmt_inconsistent = iszero(flag & IR_FLAG_CONSISTENT)
stmt = inst[:stmt]
# Special case: For getfield, we allow inconsistency of the :boundscheck argument
if is_getfield_with_boundscheck_arg(inst)
Expand All @@ -612,7 +612,7 @@ function ipo_dataflow_analysis!(interp::AbstractInterpreter, ir::IRCode, result:
return stmt_inconsistent
end

function scan_stmt!(inst, idx, lstmt, bb)
function scan_stmt!(inst::Instruction, idx::Int, lstmt::Int, bb::Int)
stmt = inst[:inst]
flag = inst[:flag]

Expand Down Expand Up @@ -705,7 +705,7 @@ function ipo_dataflow_analysis!(interp::AbstractInterpreter, ir::IRCode, result:
blockliveness = BlockLiveness(ir.cfg.blocks[bb].succs, nothing)
domtree = construct_domtree(ir.cfg.blocks)
for succ in iterated_dominance_frontier(ir.cfg, blockliveness, domtree)
visit_bb_phis!(ir, succ) do phiidx
visit_bb_phis!(ir, succ) do phiidx::Int
push!(inconsistent, phiidx)
push!(stmt_ip, phiidx)
end
Expand Down
8 changes: 4 additions & 4 deletions base/compiler/ssair/irinterp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function BBScanner(ir::IRCode)
return BBScanner(ir, bb_ip)
end

function scan!(callback, scanner::BBScanner, forwards_only::Bool)
function scan!(@specialize(callback), scanner::BBScanner, forwards_only::Bool)
(; bb_ip, ir) = scanner
bbs = ir.cfg.blocks
while !isempty(bb_ip)
Expand All @@ -235,7 +235,7 @@ function scan!(callback, scanner::BBScanner, forwards_only::Bool)
end

function populate_def_use_map!(tpdum::TwoPhaseDefUseMap, scanner::BBScanner)
scan!(scanner, false) do inst, idx, lstmt, bb
scan!(scanner, false) do inst::Instruction, idx::Int, lstmt::Int, bb::Int
for ur in userefs(inst)
val = ur[]
if isa(val, SSAValue)
Expand All @@ -262,7 +262,7 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, irsv::IR
# Fast path: Scan both use counts and refinement in one single pass of
# of the instructions. In the absence of backedges, this will
# converge.
completed_scan = scan!(scanner, true) do inst, idx, lstmt, bb
completed_scan = scan!(scanner, true) do inst::Instruction, idx::Int, lstmt::Int, bb::Int
irsv.curridx = idx
stmt = ir.stmts[idx][:inst]
typ = ir.stmts[idx][:type]
Expand Down Expand Up @@ -315,7 +315,7 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, irsv::IR
stmt_ip = BitSetBoundedMinPrioritySet(length(ir.stmts))

# Slow Path Phase 1.A: Complete use scanning
scan!(scanner, false) do inst, idx, lstmt, bb
scan!(scanner, false) do inst::Instruction, idx::Int, lstmt::Int, bb::Int
irsv.curridx = idx
stmt = inst[:inst]
flag = inst[:flag]
Expand Down
2 changes: 0 additions & 2 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ function adjust_effects(ipo_effects::Effects, def::Method)
return ipo_effects
end


function adjust_effects(sv::InferenceState)
ipo_effects = sv.ipo_effects

Expand Down Expand Up @@ -554,7 +553,6 @@ function finish(me::InferenceState, interp::AbstractInterpreter)
me.result.result = bestguess
me.ipo_effects = me.result.ipo_effects = adjust_effects(me)


if limited_ret
# a parent may be cached still, but not this intermediate work:
# we can throw everything else away now
Expand Down

0 comments on commit a32ce71

Please sign in to comment.