@@ -2017,6 +2017,12 @@ function tuple_tfunc(𝕃::AbstractLattice, argtypes::Vector{Any})
20172017 return anyinfo ? PartialStruct (𝕃, typ, argtypes) : typ
20182018end
20192019
2020+ @nospecs function memorynew_tfunc (𝕃:: AbstractLattice , memtype, m)
2021+ hasintersect (widenconst (m), Int) || return Bottom
2022+ return tmeet (𝕃, instanceof_tfunc (memtype, true )[1 ], GenericMemory)
2023+ end
2024+ add_tfunc (Core. memorynew, 2 , 2 , memorynew_tfunc, 10 )
2025+
20202026@nospecs function memoryrefget_tfunc (𝕃:: AbstractLattice , mem, order, boundscheck)
20212027 memoryref_builtin_common_errorcheck (mem, order, boundscheck) || return Bottom
20222028 return memoryref_elemtype (mem)
@@ -2244,7 +2250,16 @@ function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argt
22442250 @nospecialize (rt))
22452251 ⊑ = partialorder (𝕃)
22462252 na = length (argtypes)
2247- if f === memoryrefnew
2253+ if f === Core. memorynew
2254+ argtypes[1 ] isa Const && argtypes[2 ] isa Const || return false
2255+ MemT = argtypes[1 ]. val
2256+ isconcretetype (MemT) && MemT <: GenericMemory || return false
2257+ len = argtypes[2 ]. val
2258+ len isa Int && 0 <= len < typemax (Int) || return false
2259+ elsz = datatype_layoutsize (MemT)
2260+ checked_smul_int (len, elsz)[2 ] && return false
2261+ return true
2262+ elseif f === memoryrefnew
22482263 return memoryref_builtin_common_nothrow (argtypes)
22492264 elseif f === memoryrefoffset
22502265 length (argtypes) == 1 || return false
@@ -2347,6 +2362,7 @@ const _EFFECT_FREE_BUILTINS = [
23472362 isa,
23482363 UnionAll,
23492364 getfield,
2365+ Core. memorynew,
23502366 memoryrefnew,
23512367 memoryrefoffset,
23522368 memoryrefget,
@@ -2381,6 +2397,7 @@ const _INACCESSIBLEMEM_BUILTINS = Any[
23812397 compilerbarrier,
23822398 Core. _typevar,
23832399 donotdelete,
2400+ Core. memorynew,
23842401]
23852402
23862403const _ARGMEM_BUILTINS = Any[
@@ -2543,7 +2560,7 @@ function builtin_effects(𝕃::AbstractLattice, @nospecialize(f::Builtin), argty
25432560 consistent = ALWAYS_TRUE
25442561 elseif f === memoryrefget || f === memoryrefset! || f === memoryref_isassigned
25452562 consistent = CONSISTENT_IF_INACCESSIBLEMEMONLY
2546- elseif f === Core. _typevar
2563+ elseif f === Core. _typevar || f === Core . memorynew
25472564 consistent = CONSISTENT_IF_NOTRETURNED
25482565 else
25492566 consistent = ALWAYS_FALSE
0 commit comments