Skip to content

Commit

Permalink
some compiler housekeeping (JuliaLang#43676)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Jan 6, 2022
1 parent 8337570 commit 2d472c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 0 additions & 5 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
end
end

# inliner uses this information only when there is a single match that has been improved
# by constant analysis, but let's create `ConstCallInfo` if there has been any successful
# constant propagation happened since other consumers may be interested in this
if any_const_result && seen == napplicable
@assert napplicable == nmatches(info) == length(const_results)
info = ConstCallInfo(info, const_results)
Expand All @@ -183,7 +180,6 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
delete!(sv.pclimitations, caller)
end
end
#print("=> ", rettype, "\n")
return CallMeta(rettype, info)
end

Expand Down Expand Up @@ -1908,7 +1904,6 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
# make progress on the active ip set
local pc::Int = frame.pc´´
while true # inner loop optimizes the common case where it can run straight from pc to pc + 1
#print(pc,": ",s[pc],"\n")
local pc´::Int = pc + 1 # next program-counter (after executing instruction)
if pc == frame.pc´´
# want to update pc´´ to point at the new lowest instruction in W
Expand Down
5 changes: 1 addition & 4 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ end

function fix_va_argexprs!(compact::IncrementalCompact,
argexprs::Vector{Any}, nargs_def::Int, line_idx::Int32)
newargexprs = Any[]
for i in 1:(nargs_def-1)
push!(newargexprs, argexprs[i])
end
newargexprs = argexprs[1:(nargs_def-1)]
tuple_call = Expr(:call, TOP_TUPLE)
tuple_typs = Any[]
for i in nargs_def:length(argexprs)
Expand Down
14 changes: 8 additions & 6 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ SSADefUse() = SSADefUse(Int[], Int[], Int[])

compute_live_ins(cfg::CFG, du::SSADefUse) = compute_live_ins(cfg, du.defs, du.uses)

function try_compute_field_stmt(ir::Union{IncrementalCompact,IRCode}, stmt::Expr)
field = stmt.args[3]
# assume `stmt == getfield(obj, field, ...)` or `stmt == setfield!(obj, field, val, ...)`
try_compute_field_stmt(ir::Union{IncrementalCompact,IRCode}, stmt::Expr) =
try_compute_field(ir, stmt.args[3])

function try_compute_field(ir::Union{IncrementalCompact,IRCode}, @nospecialize(field))
# fields are usually literals, handle them manually
if isa(field, QuoteNode)
field = field.value
elseif isa(field, Int)
# try to resolve other constants, e.g. global reference
elseif isa(field, Int) || isa(field, Symbol)
else
# try to resolve other constants, e.g. global reference
field = argextype(field, ir)
if isa(field, Const)
field = field.val
else
return nothing
end
end
isa(field, Union{Int, Symbol}) || return nothing
return field
return isa(field, Union{Int, Symbol}) ? field : nothing
end

function try_compute_fieldidx_stmt(ir::Union{IncrementalCompact,IRCode}, stmt::Expr, typ::DataType)
Expand Down

0 comments on commit 2d472c6

Please sign in to comment.