@@ -2395,7 +2395,8 @@ function abstract_eval_getglobal(interp::AbstractInterpreter, sv::AbsIntState, s
2395
2395
if M isa Const && s isa Const
2396
2396
M, s = M. val, s. val
2397
2397
if M isa Module && s isa Symbol
2398
- return CallMeta (abstract_eval_globalref (interp, GlobalRef (M, s), saw_latestworld, sv), NoCallInfo ())
2398
+ (ret, bpart) = abstract_eval_globalref (interp, GlobalRef (M, s), saw_latestworld, sv)
2399
+ return CallMeta (ret, bpart === nothing ? NoCallInfo () : GlobalAccessInfo (bpart))
2399
2400
end
2400
2401
return CallMeta (Union{}, TypeError, EFFECTS_THROWS, NoCallInfo ())
2401
2402
elseif ! hasintersect (widenconst (M), Module) || ! hasintersect (widenconst (s), Symbol)
@@ -2473,8 +2474,8 @@ function abstract_eval_setglobal!(interp::AbstractInterpreter, sv::AbsIntState,
2473
2474
if isa (M, Const) && isa (s, Const)
2474
2475
M, s = M. val, s. val
2475
2476
if M isa Module && s isa Symbol
2476
- rt, exct = global_assignment_rt_exct (interp, sv, saw_latestworld, GlobalRef (M, s), v)
2477
- return CallMeta (rt, exct, Effects (setglobal!_effects, nothrow= exct=== Bottom), NoCallInfo ( ))
2477
+ ( rt, exct), partition = global_assignment_rt_exct (interp, sv, saw_latestworld, GlobalRef (M, s), v)
2478
+ return CallMeta (rt, exct, Effects (setglobal!_effects, nothrow= exct=== Bottom), GlobalAccessInfo (partition ))
2478
2479
end
2479
2480
return CallMeta (Union{}, TypeError, EFFECTS_THROWS, NoCallInfo ())
2480
2481
end
@@ -2512,15 +2513,15 @@ function abstract_eval_swapglobal!(interp::AbstractInterpreter, sv::AbsIntState,
2512
2513
scm = abstract_eval_setglobal! (interp, sv, saw_latestworld, M, s, v)
2513
2514
scm. rt === Bottom && return scm
2514
2515
gcm = abstract_eval_getglobal (interp, sv, saw_latestworld, M, s)
2515
- return CallMeta (gcm. rt, Union{scm. exct,gcm. exct}, merge_effects (scm. effects, gcm. effects), NoCallInfo () )
2516
+ return CallMeta (gcm. rt, Union{scm. exct,gcm. exct}, merge_effects (scm. effects, gcm. effects), scm . info )
2516
2517
end
2517
2518
2518
2519
function abstract_eval_swapglobal! (interp:: AbstractInterpreter , sv:: AbsIntState , saw_latestworld:: Bool ,
2519
2520
@nospecialize (M), @nospecialize (s), @nospecialize (v), @nospecialize (order))
2520
2521
scm = abstract_eval_setglobal! (interp, sv, saw_latestworld, M, s, v, order)
2521
2522
scm. rt === Bottom && return scm
2522
2523
gcm = abstract_eval_getglobal (interp, sv, saw_latestworld, M, s, order)
2523
- return CallMeta (gcm. rt, Union{scm. exct,gcm. exct}, merge_effects (scm. effects, gcm. effects), NoCallInfo () )
2524
+ return CallMeta (gcm. rt, Union{scm. exct,gcm. exct}, merge_effects (scm. effects, gcm. effects), scm . info )
2524
2525
end
2525
2526
2526
2527
function abstract_eval_swapglobal! (interp:: AbstractInterpreter , sv:: AbsIntState , saw_latestworld:: Bool , argtypes:: Vector{Any} )
@@ -2569,7 +2570,7 @@ function abstract_eval_replaceglobal!(interp::AbstractInterpreter, sv::AbsIntSta
2569
2570
end
2570
2571
exct = Union{rte. exct, global_assignment_binding_rt_exct (interp, partition, v)[2 ]}
2571
2572
effects = merge_effects (rte. effects, Effects (setglobal!_effects, nothrow= exct=== Bottom))
2572
- sg = CallMeta (Any, exct, effects, NoCallInfo ( ))
2573
+ sg = CallMeta (Any, exct, effects, GlobalAccessInfo (partition ))
2573
2574
else
2574
2575
sg = abstract_eval_setglobal! (interp, sv, saw_latestworld, M, s, v)
2575
2576
end
@@ -2937,7 +2938,8 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
2937
2938
return RTEffects (sv. ir. argtypes[e. n], Union{}, EFFECTS_TOTAL) # TODO frame_argtypes(sv)[e.n] and remove the assertion
2938
2939
end
2939
2940
elseif isa (e, GlobalRef)
2940
- return abstract_eval_globalref (interp, e, sstate. saw_latestworld, sv)
2941
+ # No need for an edge since an explicit GlobalRef will be picked up by the source scan
2942
+ return abstract_eval_globalref (interp, e, sstate. saw_latestworld, sv)[1 ]
2941
2943
end
2942
2944
if isa (e, QuoteNode)
2943
2945
e = e. value
@@ -3193,14 +3195,31 @@ function abstract_eval_isdefined_expr(interp::AbstractInterpreter, e::Expr, ssta
3193
3195
end
3194
3196
return RTEffects (rt, Union{}, EFFECTS_TOTAL)
3195
3197
end
3196
- return abstract_eval_isdefined (interp, sym, sstate. saw_latestworld, sv)
3198
+ rt = Bool
3199
+ effects = EFFECTS_TOTAL
3200
+ exct = Union{}
3201
+ if isexpr (sym, :static_parameter )
3202
+ n = sym. args[1 ]:: Int
3203
+ if 1 <= n <= length (sv. sptypes)
3204
+ sp = sv. sptypes[n]
3205
+ if ! sp. undef
3206
+ rt = Const (true )
3207
+ elseif sp. typ === Bottom
3208
+ rt = Const (false )
3209
+ end
3210
+ end
3211
+ else
3212
+ effects = EFFECTS_UNKNOWN
3213
+ exct = Any
3214
+ end
3215
+ return RTEffects (rt, exct, effects)
3197
3216
end
3198
3217
3199
3218
const generic_isdefinedglobal_effects = Effects (EFFECTS_TOTAL, consistent= ALWAYS_FALSE, nothrow= false )
3200
3219
function abstract_eval_isdefinedglobal (interp:: AbstractInterpreter , mod:: Module , sym:: Symbol , allow_import:: Union{Bool, Nothing} , saw_latestworld:: Bool , sv:: AbsIntState )
3201
3220
rt = Bool
3202
3221
if saw_latestworld
3203
- return RTEffects (rt, Union{}, Effects (generic_isdefinedglobal_effects, nothrow= true ))
3222
+ return CallMeta ( RTEffects (rt, Union{}, Effects (generic_isdefinedglobal_effects, nothrow= true )), NoCallInfo ( ))
3204
3223
end
3205
3224
3206
3225
effects = EFFECTS_TOTAL
@@ -3222,7 +3241,7 @@ function abstract_eval_isdefinedglobal(interp::AbstractInterpreter, mod::Module,
3222
3241
effects = Effects (generic_isdefinedglobal_effects, nothrow= true )
3223
3242
end
3224
3243
end
3225
- return RTEffects (rt, Union{}, effects)
3244
+ return CallMeta ( RTEffects (rt, Union{}, effects), GlobalAccessInfo (partition) )
3226
3245
end
3227
3246
3228
3247
function abstract_eval_isdefinedglobal (interp:: AbstractInterpreter , @nospecialize (M), @nospecialize (s), @nospecialize (allow_import_arg), @nospecialize (order_arg), saw_latestworld:: Bool , sv:: AbsIntState )
@@ -3247,7 +3266,7 @@ function abstract_eval_isdefinedglobal(interp::AbstractInterpreter, @nospecializ
3247
3266
if M isa Const && s isa Const
3248
3267
M, s = M. val, s. val
3249
3268
if M isa Module && s isa Symbol
3250
- return merge_exct (CallMeta ( abstract_eval_isdefinedglobal (interp, M, s, allow_import, saw_latestworld, sv), NoCallInfo () ), exct)
3269
+ return merge_exct (abstract_eval_isdefinedglobal (interp, M, s, allow_import, saw_latestworld, sv), exct)
3251
3270
end
3252
3271
return CallMeta (Union{}, TypeError, EFFECTS_THROWS, NoCallInfo ())
3253
3272
elseif ! hasintersect (widenconst (M), Module) || ! hasintersect (widenconst (s), Symbol)
@@ -3258,26 +3277,6 @@ function abstract_eval_isdefinedglobal(interp::AbstractInterpreter, @nospecializ
3258
3277
return CallMeta (Bool, Union{exct, TypeError, UndefVarError}, generic_isdefinedglobal_effects, NoCallInfo ())
3259
3278
end
3260
3279
3261
- function abstract_eval_isdefined (interp:: AbstractInterpreter , @nospecialize (sym), saw_latestworld:: Bool , sv:: AbsIntState )
3262
- rt = Bool
3263
- effects = EFFECTS_TOTAL
3264
- exct = Union{}
3265
- if isexpr (sym, :static_parameter )
3266
- n = sym. args[1 ]:: Int
3267
- if 1 <= n <= length (sv. sptypes)
3268
- sp = sv. sptypes[n]
3269
- if ! sp. undef
3270
- rt = Const (true )
3271
- elseif sp. typ === Bottom
3272
- rt = Const (false )
3273
- end
3274
- end
3275
- else
3276
- effects = EFFECTS_UNKNOWN
3277
- end
3278
- return RTEffects (rt, exct, effects)
3279
- end
3280
-
3281
3280
function abstract_eval_throw_undef_if_not (interp:: AbstractInterpreter , e:: Expr , sstate:: StatementState , sv:: AbsIntState )
3282
3281
condt = abstract_eval_value (interp, e. args[2 ], sstate, sv)
3283
3282
condval = maybe_extract_const_bool (condt)
@@ -3533,26 +3532,29 @@ end
3533
3532
3534
3533
function abstract_eval_globalref (interp:: AbstractInterpreter , g:: GlobalRef , saw_latestworld:: Bool , sv:: AbsIntState )
3535
3534
if saw_latestworld
3536
- return RTEffects ( Any, Any, generic_getglobal_effects)
3535
+ return Pair { RTEffects, Union{Nothing, Core.BindingPartition}} ( RTEffects ( Any, Any, generic_getglobal_effects), nothing )
3537
3536
end
3538
3537
partition = abstract_eval_binding_partition! (interp, g, sv)
3539
3538
ret = abstract_eval_partition_load (interp, partition)
3540
3539
if ret. rt != = Union{} && ret. exct === UndefVarError && InferenceParams (interp). assume_bindings_static
3541
3540
if isdefined (g, :binding ) && isdefined (g. binding, :value )
3542
- return RTEffects (ret. rt, Union{}, Effects (generic_getglobal_effects, nothrow= true ))
3541
+ ret = RTEffects (ret. rt, Union{}, Effects (generic_getglobal_effects, nothrow= true ))
3543
3542
end
3544
3543
# We do not assume in general that assigned global bindings remain assigned.
3545
3544
# The existence of pkgimages allows them to revert in practice.
3546
3545
end
3547
- return ret
3546
+ return Pair {RTEffects, Union{Nothing, Core.BindingPartition}} ( ret, partition)
3548
3547
end
3549
3548
3550
3549
function global_assignment_rt_exct (interp:: AbstractInterpreter , sv:: AbsIntState , saw_latestworld:: Bool , g:: GlobalRef , @nospecialize (newty))
3551
3550
if saw_latestworld
3552
- return Pair {Any,Any} (newty, Union{ErrorException, TypeError})
3551
+ return Pair {Pair{Any,Any}, Union{Core.BindingPartition, Nothing}} (
3552
+ Pair {Any,Any} (newty, Union{ErrorException, TypeError}), nothing )
3553
3553
end
3554
3554
partition = abstract_eval_binding_partition! (interp, g, sv)
3555
- return global_assignment_binding_rt_exct (interp, partition, newty)
3555
+ return Pair {Pair{Any,Any}, Union{Core.BindingPartition, Nothing}} (
3556
+ global_assignment_binding_rt_exct (interp, partition, newty),
3557
+ partition)
3556
3558
end
3557
3559
3558
3560
function global_assignment_binding_rt_exct (interp:: AbstractInterpreter , partition:: Core.BindingPartition , @nospecialize (newty))
@@ -3573,18 +3575,6 @@ function global_assignment_binding_rt_exct(interp::AbstractInterpreter, partitio
3573
3575
return Pair {Any,Any} (newty, Bottom)
3574
3576
end
3575
3577
3576
- function handle_global_assignment! (interp:: AbstractInterpreter , frame:: InferenceState , saw_latestworld:: Bool , lhs:: GlobalRef , @nospecialize (newty))
3577
- effect_free = ALWAYS_FALSE
3578
- nothrow = global_assignment_rt_exct (interp, frame, saw_latestworld, lhs, ignorelimited (newty))[2 ] === Union{}
3579
- inaccessiblememonly = ALWAYS_FALSE
3580
- if ! nothrow
3581
- sub_curr_ssaflag! (frame, IR_FLAG_NOTHROW)
3582
- end
3583
- sub_curr_ssaflag! (frame, IR_FLAG_EFFECT_FREE)
3584
- merge_effects! (interp, frame, Effects (EFFECTS_TOTAL; effect_free, nothrow, inaccessiblememonly))
3585
- return nothing
3586
- end
3587
-
3588
3578
abstract_eval_ssavalue (s:: SSAValue , sv:: InferenceState ) = abstract_eval_ssavalue (s, sv. ssavaluetypes)
3589
3579
3590
3580
function abstract_eval_ssavalue (s:: SSAValue , ssavaluetypes:: Vector{Any} )
0 commit comments