572572add_tfunc (nfields, 1 , 1 , nfields_tfunc, 1 )
573573add_tfunc (Core. _expr, 1 , INT_INF, @nospecs ((𝕃:: AbstractLattice , args... )-> Expr), 100 )
574574add_tfunc (svec, 0 , INT_INF, @nospecs ((𝕃:: AbstractLattice , args... )-> SimpleVector), 20 )
575+ @nospecs function _svec_ref_tfunc (𝕃:: AbstractLattice , s, i)
576+ if isa (s, Const) && isa (i, Const)
577+ s, i = s. val, i. val
578+ if isa (s, SimpleVector) && isa (i, Int)
579+ return 1 ≤ i ≤ length (s) ? Const (s[i]) : Bottom
580+ end
581+ end
582+ return Any
583+ end
584+ add_tfunc (Core. _svec_ref, 2 , 2 , _svec_ref_tfunc, 1 )
575585@nospecs function typevar_tfunc (𝕃:: AbstractLattice , n, lb_arg, ub_arg)
576586 lb = Union{}
577587 ub = Any
@@ -2336,6 +2346,9 @@ function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argt
23362346 elseif f === Core. compilerbarrier
23372347 na == 2 || return false
23382348 return compilerbarrier_nothrow (argtypes[1 ], nothing )
2349+ elseif f === Core. _svec_ref
2350+ na == 2 || return false
2351+ return _svec_ref_tfunc (𝕃, argtypes[1 ], argtypes[2 ]) isa Const
23392352 end
23402353 return false
23412354end
@@ -2366,7 +2379,9 @@ const _CONSISTENT_BUILTINS = Any[
23662379 throw,
23672380 Core. throw_methoderror,
23682381 setfield!,
2369- donotdelete
2382+ donotdelete,
2383+ memoryrefnew,
2384+ memoryrefoffset,
23702385]
23712386
23722387# known to be effect-free (but not necessarily nothrow)
@@ -2391,6 +2406,7 @@ const _EFFECT_FREE_BUILTINS = [
23912406 Core. throw_methoderror,
23922407 getglobal,
23932408 compilerbarrier,
2409+ Core. _svec_ref,
23942410]
23952411
23962412const _INACCESSIBLEMEM_BUILTINS = Any[
@@ -2424,6 +2440,7 @@ const _ARGMEM_BUILTINS = Any[
24242440 replacefield!,
24252441 setfield!,
24262442 swapfield!,
2443+ Core. _svec_ref,
24272444]
24282445
24292446const _INCONSISTENT_INTRINSICS = Any[
@@ -2607,9 +2624,7 @@ function builtin_effects(𝕃::AbstractLattice, @nospecialize(f::Builtin), argty
26072624 else
26082625 if contains_is (_CONSISTENT_BUILTINS, f)
26092626 consistent = ALWAYS_TRUE
2610- elseif f === memoryrefnew || f === memoryrefoffset
2611- consistent = ALWAYS_TRUE
2612- elseif f === memoryrefget || f === memoryrefset! || f === memoryref_isassigned
2627+ elseif f === memoryrefget || f === memoryrefset! || f === memoryref_isassigned || f === Core. _svec_ref
26132628 consistent = CONSISTENT_IF_INACCESSIBLEMEMONLY
26142629 elseif f === Core. _typevar || f === Core. memorynew
26152630 consistent = CONSISTENT_IF_NOTRETURNED
@@ -2795,6 +2810,8 @@ _istypemin(@nospecialize x) = !_iszero(x) && Intrinsics.neg_int(x) === x
27952810function builtin_exct (𝕃:: AbstractLattice , @nospecialize (f:: Builtin ), argtypes:: Vector{Any} , @nospecialize (rt))
27962811 if isa (f, IntrinsicFunction)
27972812 return intrinsic_exct (𝕃, f, argtypes)
2813+ elseif f === Core. _svec_ref
2814+ return BoundsError
27982815 end
27992816 return Any
28002817end
0 commit comments