From b4e218b55992d679dc66d036737dea093ccd8171 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Mon, 18 Nov 2024 07:17:37 +0000 Subject: [PATCH] More robustly use effect override internals 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. --- src/llvm_types.jl | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/llvm_types.jl b/src/llvm_types.jl index 266ceb2..b1cc972 100644 --- a/src/llvm_types.jl +++ b/src/llvm_types.jl @@ -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)