@@ -288,9 +288,6 @@ function new_expr_effect_flags(𝕃ₒ::AbstractLattice, args::Vector{Any}, src:
288288 return (false , true , true )
289289end
290290
291- assume_bindings_static (ir:: IRCode ) = ir. assume_bindings_static
292- assume_bindings_static (compact:: IncrementalCompact ) = assume_bindings_static (compact. ir)
293-
294291"""
295292 stmt_effect_flags(stmt, rt, src::Union{IRCode,IncrementalCompact}) ->
296293 (consistent::Bool, removable::Bool, nothrow::Bool)
@@ -1247,19 +1244,18 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
12471244 renumber_cfg_stmts! (sv. cfg, blockchangemap)
12481245 end
12491246
1250- meta = process_meta! (code)
1247+ meta = process_meta! (code, InferenceParams (sv . inlining . interp) . assume_bindings_static )
12511248 strip_trailing_junk! (code, ssavaluetypes, ssaflags, di, sv. cfg, stmtinfo)
12521249 types = Any[]
12531250 stmts = InstructionStream (code, types, stmtinfo, codelocs, ssaflags)
12541251 # NOTE this `argtypes` contains types of slots yet: it will be modified to contain the
12551252 # types of call arguments only once `slot2reg` converts this `IRCode` to the SSA form
12561253 # and eliminates slots (see below)
12571254 argtypes = sv. slottypes
1258- return IRCode (stmts, sv. cfg, di, argtypes, meta, sv. sptypes,
1259- InferenceParams (sv. inlining. interp). assume_bindings_static)
1255+ return IRCode (stmts, sv. cfg, di, argtypes, meta, sv. sptypes)
12601256end
12611257
1262- function process_meta! (code:: Vector{Any} )
1258+ function process_meta! (code:: Vector{Any} , assume_bindings_static :: Bool )
12631259 meta = Expr[]
12641260 for i = 1 : length (code)
12651261 stmt = code[i]
@@ -1268,9 +1264,24 @@ function process_meta!(code::Vector{Any})
12681264 code[i] = nothing
12691265 end
12701266 end
1267+ # Temporarily put the configurations of `AbstractInterpreter` that created this `IRCode`
1268+ # into `meta::Vector{Any}`, making it accessible for various optimization passes.
1269+ # The `replace_code_newstyle!` needs to filter out these temporary nodes inserted here.
1270+ pushfirst! (meta, Expr (:assume_bindings_static , assume_bindings_static))
12711271 return meta
12721272end
12731273
1274+ function assume_bindings_static (ir:: IRCode )
1275+ for node = ir. meta
1276+ node. head === :meta && break
1277+ if node. head === :assume_bindings_static
1278+ return node. args[1 ]:: Bool
1279+ end
1280+ end
1281+ return false
1282+ end
1283+ assume_bindings_static (compact:: IncrementalCompact ) = assume_bindings_static (compact. ir)
1284+
12741285function slot2reg (ir:: IRCode , ci:: CodeInfo , sv:: OptimizationState )
12751286 # need `ci` for the slot metadata, IR for the code
12761287 svdef = sv. linfo. def
0 commit comments