573
573
add_tfunc (nfields, 1 , 1 , nfields_tfunc, 1 )
574
574
add_tfunc (Core. _expr, 1 , INT_INF, @nospecs ((𝕃:: AbstractLattice , args... )-> Expr), 100 )
575
575
add_tfunc (svec, 0 , INT_INF, @nospecs ((𝕃:: AbstractLattice , args... )-> SimpleVector), 20 )
576
+ @nospecs function _svec_ref_tfunc (𝕃:: AbstractLattice , s, i)
577
+ if isa (s, Const) && isa (i, Const)
578
+ s, i = s. val, i. val
579
+ if isa (s, SimpleVector) && isa (i, Int)
580
+ return 1 ≤ i ≤ length (s) ? Const (s[i]) : Bottom
581
+ end
582
+ end
583
+ return Any
584
+ end
585
+ add_tfunc (Core. _svec_ref, 2 , 2 , _svec_ref_tfunc, 1 )
576
586
@nospecs function typevar_tfunc (𝕃:: AbstractLattice , n, lb_arg, ub_arg)
577
587
lb = Union{}
578
588
ub = Any
@@ -2316,6 +2326,9 @@ function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argt
2316
2326
elseif f === Core. compilerbarrier
2317
2327
na == 2 || return false
2318
2328
return compilerbarrier_nothrow (argtypes[1 ], nothing )
2329
+ elseif f === Core. _svec_ref
2330
+ na == 2 || return false
2331
+ return _svec_ref_tfunc (𝕃, argtypes[1 ], argtypes[2 ]) isa Const
2319
2332
end
2320
2333
return false
2321
2334
end
@@ -2346,7 +2359,9 @@ const _CONSISTENT_BUILTINS = Any[
2346
2359
throw,
2347
2360
Core. throw_methoderror,
2348
2361
setfield!,
2349
- donotdelete
2362
+ donotdelete,
2363
+ memoryrefnew,
2364
+ memoryrefoffset,
2350
2365
]
2351
2366
2352
2367
# known to be effect-free (but not necessarily nothrow)
@@ -2371,6 +2386,7 @@ const _EFFECT_FREE_BUILTINS = [
2371
2386
Core. throw_methoderror,
2372
2387
getglobal,
2373
2388
compilerbarrier,
2389
+ Core. _svec_ref,
2374
2390
]
2375
2391
2376
2392
const _INACCESSIBLEMEM_BUILTINS = Any[
@@ -2404,6 +2420,7 @@ const _ARGMEM_BUILTINS = Any[
2404
2420
replacefield!,
2405
2421
setfield!,
2406
2422
swapfield!,
2423
+ Core. _svec_ref,
2407
2424
]
2408
2425
2409
2426
const _INCONSISTENT_INTRINSICS = Any[
@@ -2546,7 +2563,7 @@ const _EFFECTS_KNOWN_BUILTINS = Any[
2546
2563
# Core._primitivetype,
2547
2564
# Core._setsuper!,
2548
2565
# Core._structtype,
2549
- # Core._svec_ref,
2566
+ Core. _svec_ref,
2550
2567
# Core._typebody!,
2551
2568
Core. _typevar,
2552
2569
apply_type,
@@ -2650,9 +2667,7 @@ function builtin_effects(𝕃::AbstractLattice, @nospecialize(f::Builtin), argty
2650
2667
else
2651
2668
if contains_is (_CONSISTENT_BUILTINS, f)
2652
2669
consistent = ALWAYS_TRUE
2653
- elseif f === memoryrefnew || f === memoryrefoffset
2654
- consistent = ALWAYS_TRUE
2655
- elseif f === memoryrefget || f === memoryrefset! || f === memoryref_isassigned
2670
+ elseif f === memoryrefget || f === memoryrefset! || f === memoryref_isassigned || f === Core. _svec_ref
2656
2671
consistent = CONSISTENT_IF_INACCESSIBLEMEMONLY
2657
2672
elseif f === Core. _typevar || f === Core. memorynew
2658
2673
consistent = CONSISTENT_IF_NOTRETURNED
@@ -2838,6 +2853,8 @@ _istypemin(@nospecialize x) = !_iszero(x) && Intrinsics.neg_int(x) === x
2838
2853
function builtin_exct (𝕃:: AbstractLattice , @nospecialize (f:: Builtin ), argtypes:: Vector{Any} , @nospecialize (rt))
2839
2854
if isa (f, IntrinsicFunction)
2840
2855
return intrinsic_exct (𝕃, f, argtypes)
2856
+ elseif f === Core. _svec_ref
2857
+ return BoundsError
2841
2858
end
2842
2859
return Any
2843
2860
end
0 commit comments