Skip to content

Commit

Permalink
make statement_costs! accept IRCode (JuliaLang#41257)
Browse files Browse the repository at this point in the history
I want to use this in Cthulhu, which uses `IRCode` for optimized code
instead of `CodeInfo`.
  • Loading branch information
simeonschaub committed Jun 18, 2021
1 parent b34aa1e commit 083272b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,14 @@ function inline_worthy(ir::IRCode,
return true
end

function statement_costs!(cost::Vector{Int}, body::Vector{Any}, src::CodeInfo, sptypes::Vector{Any}, unionpenalties::Bool, params::OptimizationParams)
function statement_costs!(cost::Vector{Int}, body::Vector{Any}, src::Union{CodeInfo, IRCode}, sptypes::Vector{Any}, unionpenalties::Bool, params::OptimizationParams)
throw_blocks = params.unoptimize_throw_blocks ? find_throw_blocks(body) : nothing
maxcost = 0
for line = 1:length(body)
stmt = body[line]
thiscost = statement_or_branch_cost(stmt, line, src, sptypes, src.slottypes, unionpenalties, params, throw_blocks)
thiscost = statement_or_branch_cost(stmt, line, src, sptypes,
src isa CodeInfo ? src.slottypes : src.argtypes,
unionpenalties, params, throw_blocks)
cost[line] = thiscost
if thiscost > maxcost
maxcost = thiscost
Expand Down

0 comments on commit 083272b

Please sign in to comment.