diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 3c0f3336d6435..46e15d0c3ad79 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -1709,7 +1709,7 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si:: return CallMeta(res, exct, effects, retinfo) end -function argtype_by_index(argtypes::Vector{Any}, i::Integer) +function argtype_by_index(argtypes::Vector{Any}, i::Int) n = length(argtypes) na = argtypes[n] if isvarargtype(na) @@ -2880,12 +2880,12 @@ end struct BestguessInfo{Interp<:AbstractInterpreter} interp::Interp bestguess - nargs::UInt + nargs::Int slottypes::Vector{Any} changes::VarTable - function BestguessInfo(interp::Interp, @nospecialize(bestguess), nargs::UInt, + function BestguessInfo(interp::Interp, @nospecialize(bestguess), nargs::Int, slottypes::Vector{Any}, changes::VarTable) where Interp<:AbstractInterpreter - new{Interp}(interp, bestguess, Int(nargs), slottypes, changes) + new{Interp}(interp, bestguess, nargs, slottypes, changes) end end diff --git a/base/compiler/inferenceresult.jl b/base/compiler/inferenceresult.jl index 8d8aec0462853..7da96c4cc2e93 100644 --- a/base/compiler/inferenceresult.jl +++ b/base/compiler/inferenceresult.jl @@ -36,44 +36,44 @@ function pick_const_arg(𝕃::AbstractLattice, @nospecialize(given_argtype), @no # declared method signature, narrow it down using `tmeet` given_argtype = tmeet(𝕃, given_argtype, cache_argtype) end + return given_argtype else - given_argtype = cache_argtype + return cache_argtype end - return given_argtype end function pick_const_args!(𝕃::AbstractLattice, given_argtypes::Vector{Any}, cache_argtypes::Vector{Any}) - if length(given_argtypes) == 0 || length(cache_argtypes) == 0 + ngiven = length(given_argtypes) + ncache = length(cache_argtypes) + if ngiven == 0 || ncache == 0 return Any[] end given_va = given_argtypes[end] cache_va = cache_argtypes[end] if isvarargtype(given_va) - ngiven = length(given_argtypes) va = unwrapva(given_va) if isvarargtype(cache_va) # Process the common prefix, then join - nprocessargs = max(length(given_argtypes)-1, length(cache_argtypes)-1) + nprocessargs = max(ngiven-1, ncache-1) resize!(given_argtypes, nprocessargs+1) - given_argtypes[end] = Vararg{pick_const_arg(𝕃, unwrapva(given_va), unwrapva(cache_va))} + given_argtypes[end] = Vararg{pick_const_arg(𝕃, va, unwrapva(cache_va))} else - nprocessargs = length(cache_argtypes) + nprocessargs = ncache resize!(given_argtypes, nprocessargs) end for i = ngiven:nprocessargs given_argtypes[i] = va end elseif isvarargtype(cache_va) - nprocessargs = length(given_argtypes) + nprocessargs = ngiven else - @assert length(given_argtypes) == length(cache_argtypes) - nprocessargs = length(given_argtypes) + @assert ngiven == ncache + nprocessargs = ngiven end for i = 1:nprocessargs given_argtype = given_argtypes[i] cache_argtype = argtype_by_index(cache_argtypes, i) - given_argtype = pick_const_arg(𝕃, given_argtype, cache_argtype) - given_argtypes[i] = given_argtype + given_argtypes[i] = pick_const_arg(𝕃, given_argtype, cache_argtype) end return given_argtypes end @@ -90,8 +90,9 @@ function is_argtype_match(𝕃::AbstractLattice, end function va_process_argtypes(𝕃::AbstractLattice, given_argtypes::Vector{Any}, nargs::UInt, isva::Bool) + nargs = Int(nargs) if isva || (!isempty(given_argtypes) && isvarargtype(given_argtypes[end])) - isva_given_argtypes = Vector{Any}(undef, Int(nargs)) + isva_given_argtypes = Vector{Any}(undef, nargs) for i = 1:(nargs-isva) newarg = argtype_by_index(given_argtypes, i) if isva && has_conditional(𝕃) && isa(newarg, Conditional) @@ -126,7 +127,7 @@ end function most_general_argtypes(method::Union{Method,Nothing}, @nospecialize(specTypes)) mi_argtypes = Any[(unwrap_unionall(specTypes)::DataType).parameters...] nargtypes = length(mi_argtypes) - nargs = isa(method, Method) ? method.nargs : 0 + nargs = isa(method, Method) ? Int(method.nargs) : 0 if length(mi_argtypes) < nargs && isvarargtype(mi_argtypes[end]) resize!(mi_argtypes, nargs) end diff --git a/base/compiler/inferencestate.jl b/base/compiler/inferencestate.jl index 75e947af6dac2..e26845b9da1f0 100644 --- a/base/compiler/inferencestate.jl +++ b/base/compiler/inferencestate.jl @@ -853,7 +853,7 @@ function print_callstack(sv::InferenceState) end function narguments(sv::InferenceState, include_va::Bool=true) - nargs = sv.src.nargs + nargs = Int(sv.src.nargs) if !include_va nargs -= sv.src.isva end diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 36b8114795410..ec206e47103ed 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -1254,7 +1254,7 @@ function slot2reg(ir::IRCode, ci::CodeInfo, sv::OptimizationState) # need `ci` for the slot metadata, IR for the code svdef = sv.linfo.def @timeit "domtree 1" domtree = construct_domtree(ir) - defuse_insts = scan_slot_def_use(ci.nargs, ci, ir.stmts.stmt) + defuse_insts = scan_slot_def_use(Int(ci.nargs), ci, ir.stmts.stmt) 𝕃ₒ = optimizer_lattice(sv.inlining.interp) @timeit "construct_ssa" ir = construct_ssa!(ci, ir, sv, domtree, defuse_insts, 𝕃ₒ) # consumes `ir` # NOTE now we have converted `ir` to the SSA form and eliminated slots diff --git a/base/compiler/ssair/slot2ssa.jl b/base/compiler/ssair/slot2ssa.jl index 1eedc09e01530..756dc98863af5 100644 --- a/base/compiler/ssair/slot2ssa.jl +++ b/base/compiler/ssair/slot2ssa.jl @@ -33,7 +33,7 @@ function scan_entry!(result::Vector{SlotInfo}, idx::Int, @nospecialize(stmt)) end end -function scan_slot_def_use(nargs::Integer, ci::CodeInfo, code::Vector{Any}) +function scan_slot_def_use(nargs::Int, ci::CodeInfo, code::Vector{Any}) nslots = length(ci.slotflags) result = SlotInfo[SlotInfo() for i = 1:nslots] # Set defs for arguments diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index ee3e93806f853..d091fb8d2f5f8 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -468,7 +468,7 @@ function adjust_effects(sv::InferenceState) # this frame is known to be safe ipo_effects = Effects(ipo_effects; nothrow=true) end - if is_inaccessiblemem_or_argmemonly(ipo_effects) && all(1:narguments(sv, #=include_va=#true)) do i::UInt + if is_inaccessiblemem_or_argmemonly(ipo_effects) && all(1:narguments(sv, #=include_va=#true)) do i::Int return is_mutation_free_argtype(sv.slottypes[i]) end ipo_effects = Effects(ipo_effects; inaccessiblememonly=ALWAYS_TRUE)