Skip to content

Commit

Permalink
More robustly use effect override internals
Browse files Browse the repository at this point in the history
The effect override ABI is unstable. The current way it's being
used is somewhat problematic: In release mode, it may silently
stop working or apply the wrong effects and in debug mode it
asserts. Instead, use the julia-level APIs, which have keyword
arg constructors that are slightly more stable and will at least
error consistently.
  • Loading branch information
Keno committed Nov 18, 2024
1 parent e92384e commit b4e218b
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/llvm_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,33 @@ end
end
callonly && return call
meta = if VERSION v"1.8.0-beta"
purity = if touchesmemory
Expr(:purity, false, false, true, true, false)
if VERSION >= v"1.12.0-DEV.1406"
purity = Base.form_purity_expr(Base.EffectsOverride(;
consistent=!touchesmemory,
effect_free=!touchesmemory,
nothrow=true,
terminates_globally=true,
terminates_locally=true,
notaskstate=true,
inaccessiblememonly=true,
noub=true,
nortcall=true,
))
else
Expr(:purity, true, true, true, true, false)
purity = if touchesmemory
Expr(:purity, false, false, true, true, false)
else
Expr(:purity, true, true, true, true, false)
end
VERSION >= v"1.9.0-DEV.1019" && push!(purity.args, true)
VERSION >= v"1.11" && push!(purity.args,
#= inaccessiblememonly =# true,
#= noub =# true,
#= noub_if_noinbounds =# false,
#= consistent_overlay =# false,
#= nortcall =# true,
)
end
VERSION >= v"1.9.0-DEV.1019" && push!(purity.args, true)
VERSION >= v"1.11" && push!(purity.args,
#= inaccessiblememonly =# true,
#= noub =# true,
#= noub_if_noinbounds =# false,
#= consistent_overlay =# false,
#= nortcall =# true,
)
Expr(:meta, purity, :inline)
else
Expr(:meta, :inline)
Expand Down

0 comments on commit b4e218b

Please sign in to comment.