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 5, 2023
1 parent e2a79f4 commit dd58e9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,16 +564,16 @@ 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

function scan_non_dataflow_flags!(inst::Instruction)
flag = inst[:flag]
all_effect_free &= (flag & IR_FLAG_EFFECT_FREE) != 0
all_nothrow &= (flag & IR_FLAG_NOTHROW) != 0
if (flag & IR_FLAG_NOUB) == 0
all_effect_free &= !iszero(flag & IR_FLAG_EFFECT_FREE)
all_nothrow &= !iszero(flag & IR_FLAG_NOTHROW)
if iszero(flag & IR_FLAG_NOUB)
if !is_conditional_noub(inst)
all_noub = false
end
Expand All @@ -582,7 +582,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 @@ -606,7 +606,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
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 dd58e9e

Please sign in to comment.