@@ -303,19 +303,19 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
303
303
boundscheck:: Symbol , todo_bbs:: Vector{Tuple{Int, Int}} )
304
304
# Ok, do the inlining here
305
305
inline_cfg = item. ir. cfg
306
- stmt = compact. result[idx]
307
- linetable_offset = length (linetable)
306
+ stmt = compact. result[idx][ :inst ]
307
+ linetable_offset:: Int32 = length (linetable)
308
308
# Append the linetable of the inlined function to our line table
309
- inlined_at = Int (compact. result_lines [idx])
309
+ inlined_at = Int (compact. result [idx][ :line ])
310
310
for entry in item. linetable
311
311
push! (linetable, LineInfoNode (entry. method, entry. file, entry. line,
312
312
(entry. inlined_at > 0 ? entry. inlined_at + linetable_offset : inlined_at)))
313
313
end
314
314
if item. isva
315
- vararg = mk_tuplecall! (compact, argexprs[item. na: end ], compact. result_lines [idx])
315
+ vararg = mk_tuplecall! (compact, argexprs[item. na: end ], compact. result [idx][ :line ])
316
316
argexprs = Any[argexprs[1 : (item. na - 1 )]. .. , vararg]
317
317
end
318
- flag = compact. result_flags [idx]
318
+ flag = compact. result [idx][ :flag ]
319
319
boundscheck_idx = boundscheck
320
320
if boundscheck_idx === :default || boundscheck_idx === :propagate
321
321
if (flag & IR_FLAG_INBOUNDS) != 0
@@ -341,7 +341,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
341
341
return_value = SSAValue (idx′)
342
342
inline_compact[idx′] = stmt′. val
343
343
val = stmt′. val
344
- inline_compact. result_types [idx′] = (isa (val, Argument) || isa (val, Expr)) ?
344
+ inline_compact. result [idx′][ :type ] = (isa (val, Argument) || isa (val, Expr)) ?
345
345
compact_exprtype (compact, stmt′. val) :
346
346
compact_exprtype (inline_compact, stmt′. val)
347
347
break
@@ -371,11 +371,11 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
371
371
push! (pn. edges, inline_compact. active_result_bb- 1 )
372
372
if isa (val, GlobalRef) || isa (val, Expr)
373
373
stmt′ = val
374
- inline_compact. result_types [idx′] = (isa (val, Argument) || isa (val, Expr)) ?
374
+ inline_compact. result [idx′][ :type ] = (isa (val, Argument) || isa (val, Expr)) ?
375
375
compact_exprtype (compact, val) :
376
376
compact_exprtype (inline_compact, val)
377
377
insert_node_here! (inline_compact, GotoNode (post_bb_id),
378
- Any, compact. result_lines [idx′],
378
+ Any, compact. result [idx′][ :line ],
379
379
true )
380
380
push! (pn. values, SSAValue (idx′))
381
381
else
@@ -407,7 +407,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
407
407
if length (pn. edges) == 1
408
408
return_value = pn. values[1 ]
409
409
else
410
- return_value = insert_node_here! (compact, pn, compact_exprtype (compact, SSAValue (idx)), compact. result_lines [idx])
410
+ return_value = insert_node_here! (compact, pn, compact_exprtype (compact, SSAValue (idx)), compact. result [idx][ :line ])
411
411
end
412
412
end
413
413
return_value
@@ -418,7 +418,7 @@ const fatal_type_bound_error = ErrorException("fatal error in type inference (ty
418
418
function ir_inline_unionsplit! (compact:: IncrementalCompact , idx:: Int ,
419
419
argexprs:: Vector{Any} , linetable:: Vector{LineInfoNode} ,
420
420
item:: UnionSplit , boundscheck:: Symbol , todo_bbs:: Vector{Tuple{Int, Int}} )
421
- stmt, typ, line = compact. result[idx], compact. result_types [idx], compact. result_lines [idx]
421
+ stmt, typ, line = compact. result[idx][ :inst ] , compact. result [idx][ :type ] , compact. result [idx][ :line ]
422
422
atype = item. atype
423
423
generic_bb = item. bbs[end - 1 ]
424
424
join_bb = item. bbs[end ]
@@ -541,12 +541,13 @@ function batch_inline!(todo::Vector{Any}, ir::IRCode, linetable::Vector{LineInfo
541
541
for aidx in 1 : length (argexprs)
542
542
aexpr = argexprs[aidx]
543
543
if isa (aexpr, GlobalRef) || isa (aexpr, Expr)
544
- argexprs[aidx] = insert_node_here! (compact, aexpr, compact_exprtype (compact, aexpr), compact. result_lines [idx])
544
+ argexprs[aidx] = insert_node_here! (compact, aexpr, compact_exprtype (compact, aexpr), compact. result [idx][ :line ])
545
545
end
546
546
end
547
547
if isinvoke (item)
548
- argexprs = rewrite_invoke_exprargs! ((node, typ)-> insert_node_here! (compact, node, typ, compact. result_lines[idx]),
549
- argexprs)
548
+ argexprs = rewrite_invoke_exprargs! (argexprs) do node, typ
549
+ insert_node_here! (compact, node, typ, compact. result[idx][:line ])
550
+ end
550
551
end
551
552
if isa (item, InliningTodo)
552
553
compact. ssa_rename[compact. idx- 1 ] = ir_inline_item! (compact, idx, argexprs, linetable, item, boundscheck, state. todo_bbs)
@@ -841,8 +842,8 @@ function is_valid_type_for_apply_rewrite(@nospecialize(typ), params::Optimizatio
841
842
end
842
843
843
844
function inline_splatnew! (ir:: IRCode , idx:: Int )
844
- stmt = ir. stmts[idx]
845
- ty = ir. types [idx]
845
+ stmt = ir. stmts[idx][ :inst ]
846
+ ty = ir. stmts [idx][ :type ]
846
847
nf = nfields_tfunc (ty)
847
848
if nf isa Const
848
849
eargs = stmt. args
@@ -874,7 +875,6 @@ function call_sig(ir::IRCode, stmt::Expr)
874
875
f = singleton_type (ft)
875
876
f === Core. Intrinsics. llvmcall && return nothing
876
877
f === Core. Intrinsics. cglobal && return nothing
877
-
878
878
atypes = Vector {Any} (undef, length (stmt. args))
879
879
atypes[1 ] = ft
880
880
ok = true
@@ -888,7 +888,7 @@ function call_sig(ir::IRCode, stmt::Expr)
888
888
end
889
889
890
890
function inline_apply! (ir:: IRCode , idx:: Int , sig:: Signature , params:: OptimizationParams )
891
- stmt = ir. stmts[idx]
891
+ stmt = ir. stmts[idx][ :inst ]
892
892
while sig. f === Core. _apply || sig. f === Core. _apply_iterate
893
893
arg_start = sig. f === Core. _apply ? 2 : 3
894
894
atypes = sig. atypes
@@ -911,7 +911,7 @@ function inline_apply!(ir::IRCode, idx::Int, sig::Signature, params::Optimizatio
911
911
break
912
912
end
913
913
if nonempty_idx != 0
914
- ir. stmts[idx] = stmt. args[nonempty_idx]
914
+ ir. stmts[idx][ :inst ] = stmt. args[nonempty_idx]
915
915
return nothing
916
916
end
917
917
end
@@ -941,8 +941,8 @@ is_builtin(s::Signature) =
941
941
s. ft ⊑ Builtin
942
942
943
943
function inline_invoke! (ir:: IRCode , idx:: Int , sig:: Signature , invoke_data:: InvokeData , sv:: OptimizationState , todo:: Vector{Any} )
944
- stmt = ir. stmts[idx]
945
- calltype = ir. types [idx]
944
+ stmt = ir. stmts[idx][ :inst ]
945
+ calltype = ir. stmts [idx][ :type ]
946
946
method = invoke_data. entry. func
947
947
(metharg, methsp) = ccall (:jl_type_intersection_with_env , Any, (Any, Any),
948
948
sig. atype, method. sig):: SimpleVector
958
958
# this method does not access the method table or otherwise process generic
959
959
# functions.
960
960
function process_simple! (ir:: IRCode , idx:: Int , params:: OptimizationParams , world:: UInt )
961
- stmt = ir. stmts[idx]
961
+ stmt = ir. stmts[idx][ :inst ]
962
962
stmt isa Expr || return nothing
963
963
if stmt. head === :splatnew
964
964
inline_splatnew! (ir, idx)
@@ -975,10 +975,10 @@ function process_simple!(ir::IRCode, idx::Int, params::OptimizationParams, world
975
975
sig === nothing && return nothing
976
976
977
977
# Check if we match any of the early inliners
978
- calltype = ir. types [idx]
978
+ calltype = ir. stmts [idx][ :type ]
979
979
res = early_inline_special_case (ir, sig, stmt, params, calltype)
980
980
if res != = nothing
981
- ir. stmts[idx] = res
981
+ ir. stmts[idx][ :inst ] = res
982
982
return nothing
983
983
end
984
984
@@ -1013,8 +1013,8 @@ function assemble_inline_todo!(ir::IRCode, sv::OptimizationState)
1013
1013
r = process_simple! (ir, idx, sv. params, sv. world)
1014
1014
r === nothing && continue
1015
1015
1016
- stmt = ir. stmts[idx]
1017
- calltype = ir. types [idx]
1016
+ stmt = ir. stmts[idx][ :inst ]
1017
+ calltype = ir. stmts [idx][ :type ]
1018
1018
(sig, invoke_data) = r
1019
1019
1020
1020
# Ok, now figure out what method to call
@@ -1213,8 +1213,8 @@ function early_inline_special_case(ir::IRCode, s::Signature, e::Expr, params::Op
1213
1213
end
1214
1214
1215
1215
function late_inline_special_case! (ir:: IRCode , sig:: Signature , idx:: Int , stmt:: Expr , params:: OptimizationParams )
1216
- typ = ir. types[idx]
1217
1216
f, ft, atypes = sig. f, sig. ft, sig. atypes
1217
+ typ = ir. stmts[idx][:type ]
1218
1218
if params. inlining && length (atypes) == 3 && istopfunction (f, :!= = )
1219
1219
# special-case inliner for !== that precedes _methods_by_ftype union splitting
1220
1220
# and that works, even though inference generally avoids inferring the `!==` Method
@@ -1251,9 +1251,9 @@ end
1251
1251
1252
1252
function ssa_substitute! (idx:: Int , @nospecialize (val), arg_replacements:: Vector{Any} ,
1253
1253
@nospecialize (spsig), spvals:: Vector{Any} ,
1254
- linetable_offset:: Int , boundscheck:: Symbol , compact:: IncrementalCompact )
1255
- compact. result_flags [idx] &= ~ IR_FLAG_INBOUNDS
1256
- compact. result_lines [idx] += linetable_offset
1254
+ linetable_offset:: Int32 , boundscheck:: Symbol , compact:: IncrementalCompact )
1255
+ compact. result [idx][ :flag ] &= ~ IR_FLAG_INBOUNDS
1256
+ compact. result [idx][ :line ] += linetable_offset
1257
1257
return ssa_substitute_op! (val, arg_replacements, spsig, spvals, boundscheck)
1258
1258
end
1259
1259
0 commit comments