From 249dd8e3f5fe1ed01efc20ed5cdb44338060a5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Fri, 28 Feb 2025 14:25:05 -0500 Subject: [PATCH 1/7] Adapt to https://github.com/JuliaLang/julia/pull/57545 --- src/interpreter.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/interpreter.jl b/src/interpreter.jl index 6b3aaf31..778ce4d2 100644 --- a/src/interpreter.jl +++ b/src/interpreter.jl @@ -105,12 +105,22 @@ function InferredSource(state::InferenceState) exct) end +@static if VERSION ≥ v"1.13.0-DEV.126" +function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) + res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int) + key = CC.is_constproped(state) + interp.unopt[key] = InferredSource(state) + return res +end + +else function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter) res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter) key = (@static VERSION ≥ v"1.12.0-DEV.317" ? CC.is_constproped(state) : CC.any(state.result.overridden_by_const)) ? state.result : state.linfo interp.unopt[key] = InferredSource(state) return res end +end function create_cthulhu_source(@nospecialize(opt), effects::Effects) isa(opt, OptimizationState) || return opt @@ -128,7 +138,9 @@ function set_cthulhu_source!(result::InferenceResult) result.src = create_cthulhu_source(result.src, result.ipo_effects) end -@static if VERSION ≥ v"1.12.0-DEV.1823" +@static if VERSION ≥ v"1.13.0-DEV.126" +CC.finishinfer!(state::InferenceState, interp::ADInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid::Int) +elseif VERSION ≥ v"1.12.0-DEV.1823" CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter) = cthulhu_finish(CC.finishinfer!, state, interp) @static if VERSION ≥ v"1.12.0-DEV.1988" function CC.finish!(interp::CthulhuInterpreter, caller::InferenceState, validation_world::UInt) From 9359fc8ec510c32b02e572cfa5dab2729cb708f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Fri, 28 Feb 2025 14:25:05 -0500 Subject: [PATCH 2/7] Adapt to https://github.com/JuliaLang/julia/pull/57545 --- src/interpreter.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/interpreter.jl b/src/interpreter.jl index 6b3aaf31..dcd68b2a 100644 --- a/src/interpreter.jl +++ b/src/interpreter.jl @@ -105,12 +105,22 @@ function InferredSource(state::InferenceState) exct) end +@static if VERSION ≥ v"1.13.0-DEV.126" +function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) + res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int) + key = CC.is_constproped(state) + interp.unopt[key] = InferredSource(state) + return res +end + +else function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter) res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter) key = (@static VERSION ≥ v"1.12.0-DEV.317" ? CC.is_constproped(state) : CC.any(state.result.overridden_by_const)) ? state.result : state.linfo interp.unopt[key] = InferredSource(state) return res end +end function create_cthulhu_source(@nospecialize(opt), effects::Effects) isa(opt, OptimizationState) || return opt @@ -128,7 +138,9 @@ function set_cthulhu_source!(result::InferenceResult) result.src = create_cthulhu_source(result.src, result.ipo_effects) end -@static if VERSION ≥ v"1.12.0-DEV.1823" +@static if VERSION ≥ v"1.13.0-DEV.126" +CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid::Int) +elseif VERSION ≥ v"1.12.0-DEV.1823" CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter) = cthulhu_finish(CC.finishinfer!, state, interp) @static if VERSION ≥ v"1.12.0-DEV.1988" function CC.finish!(interp::CthulhuInterpreter, caller::InferenceState, validation_world::UInt) From d55e46bdf26e1b65ffa0a0033e66ab6560820cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Fri, 28 Feb 2025 16:46:17 -0500 Subject: [PATCH 3/7] Fixes --- src/interpreter.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/interpreter.jl b/src/interpreter.jl index bbb02729..af96c713 100644 --- a/src/interpreter.jl +++ b/src/interpreter.jl @@ -105,7 +105,7 @@ function InferredSource(state::InferenceState) exct) end -@static if VERSION ≥ v"1.13.0-DEV.126" +@static if VERSION ≥ v"1.13.0-DEV.126" || VERSION ≥ v"1.12.0-alpha1" function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int) key = CC.is_constproped(state) ? state.result : state.linfo @@ -138,10 +138,12 @@ function set_cthulhu_source!(result::InferenceResult) result.src = create_cthulhu_source(result.src, result.ipo_effects) end -@static if VERSION ≥ v"1.13.0-DEV.126" -CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid::Int) -elseif VERSION ≥ v"1.12.0-DEV.1823" +@static if VERSION ≥ v"1.12.0-DEV.1823" +@static if VERSION ≥ v"1.13.0-DEV.126" || VERSION ≥ v"1.12.0-alpha1" +CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid) +else CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter) = cthulhu_finish(CC.finishinfer!, state, interp) +end @static if VERSION ≥ v"1.12.0-DEV.1988" function CC.finish!(interp::CthulhuInterpreter, caller::InferenceState, validation_world::UInt) set_cthulhu_source!(caller.result) From dd86ef042364f9aca09987f10f0fc9419bea0ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Fri, 28 Feb 2025 16:49:15 -0500 Subject: [PATCH 4/7] Bump version --- Project.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 2f60d40a..ff2bc539 100644 --- a/Project.toml +++ b/Project.toml @@ -1,11 +1,10 @@ name = "Cthulhu" uuid = "f68482b8-f384-11e8-15f7-abe071a5a75f" -version = "2.16.3" +version = "2.16.4" authors = ["Valentin Churavy and contributors"] [deps] CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" FoldingTrees = "1eca21be-9b9b-4ed8-839a-6d8ae26b1781" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JuliaSyntax = "70703baa-626e-46a2-a12c-08ffd08c73b4" @@ -19,7 +18,6 @@ WidthLimitedIO = "b8c1c048-cf81-46c6-9da0-18c1d99e41f2" [compat] CodeTracking = "0.5, 1" -Compiler = "0.0.3" FoldingTrees = "1" InteractiveUtils = "1.9" JuliaSyntax = "0.4" From 6ec72ec1de922e7c14b391955e17e9ac29fcaeec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Sat, 1 Mar 2025 05:38:57 -0500 Subject: [PATCH 5/7] Add tighter version checks --- src/interpreter.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter.jl b/src/interpreter.jl index af96c713..4b8cde23 100644 --- a/src/interpreter.jl +++ b/src/interpreter.jl @@ -105,7 +105,7 @@ function InferredSource(state::InferenceState) exct) end -@static if VERSION ≥ v"1.13.0-DEV.126" || VERSION ≥ v"1.12.0-alpha1" +@static if VERSION ≥ v"1.13.0-DEV.126" || v"1.12.0-alpha1" ≤ VERSION < v"1.13" function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int) key = CC.is_constproped(state) ? state.result : state.linfo @@ -139,7 +139,7 @@ function set_cthulhu_source!(result::InferenceResult) end @static if VERSION ≥ v"1.12.0-DEV.1823" -@static if VERSION ≥ v"1.13.0-DEV.126" || VERSION ≥ v"1.12.0-alpha1" +@static if VERSION ≥ v"1.13.0-DEV.126" || v"1.12.0-alpha1" ≤ VERSION < v"1.13" CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid) else CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter) = cthulhu_finish(CC.finishinfer!, state, interp) From 29f4947d3e4cb5c57f0810038cb9b29729894d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Sat, 1 Mar 2025 05:40:08 -0500 Subject: [PATCH 6/7] Revert accidental edit --- Project.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Project.toml b/Project.toml index ff2bc539..f7bac45f 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ authors = ["Valentin Churavy and contributors"] [deps] CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" +Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" FoldingTrees = "1eca21be-9b9b-4ed8-839a-6d8ae26b1781" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JuliaSyntax = "70703baa-626e-46a2-a12c-08ffd08c73b4" @@ -18,6 +19,7 @@ WidthLimitedIO = "b8c1c048-cf81-46c6-9da0-18c1d99e41f2" [compat] CodeTracking = "0.5, 1" +Compiler = "0.0.3" FoldingTrees = "1" InteractiveUtils = "1.9" JuliaSyntax = "0.4" From 95615ac4d88dc3b5ce5be337be6c3e37f6576ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belmant?= Date: Mon, 3 Mar 2025 13:19:17 -0500 Subject: [PATCH 7/7] Simplify version checks --- src/interpreter.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter.jl b/src/interpreter.jl index 4b8cde23..f8075571 100644 --- a/src/interpreter.jl +++ b/src/interpreter.jl @@ -105,7 +105,7 @@ function InferredSource(state::InferenceState) exct) end -@static if VERSION ≥ v"1.13.0-DEV.126" || v"1.12.0-alpha1" ≤ VERSION < v"1.13" +@static if VERSION ≥ v"1.12.0-alpha1" function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int) key = CC.is_constproped(state) ? state.result : state.linfo @@ -139,7 +139,7 @@ function set_cthulhu_source!(result::InferenceResult) end @static if VERSION ≥ v"1.12.0-DEV.1823" -@static if VERSION ≥ v"1.13.0-DEV.126" || v"1.12.0-alpha1" ≤ VERSION < v"1.13" +@static if VERSION ≥ v"1.12.0-alpha1" CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid) else CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter) = cthulhu_finish(CC.finishinfer!, state, interp)