From 0c9292f1b9243b0e8d4d0f6b5bf40cf5a9359b7c Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 18 Apr 2024 20:57:53 +0200 Subject: [PATCH] Add an interface extension point to prepare before anything happens. (#572) --- src/driver.jl | 2 ++ src/interface.jl | 4 ++++ src/jlgen.jl | 1 + 3 files changed, 7 insertions(+) diff --git a/src/driver.jl b/src/driver.jl index f92e6182..bc12fd87 100644 --- a/src/driver.jl +++ b/src/driver.jl @@ -128,6 +128,8 @@ function codegen(output::Symbol, @nospecialize(job::CompilerJob); validate && check_invocation(job) end + prepare_job!(job) + ## LLVM IR diff --git a/src/interface.jl b/src/interface.jl index 53579839..2c9724f9 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -277,6 +277,10 @@ end ## extension points at important stages of compilation +# prepare the environment for compilation of a job. this can involve, e.g., +# priming the cache with entries that cannot be easily inferred. +prepare_job!(@nospecialize(job::CompilerJob)) = return + # early extension point used to link-in external bitcode files. # this is typically used by downstream packages to link vendor libraries. link_libraries!(@nospecialize(job::CompilerJob), mod::LLVM.Module, diff --git a/src/jlgen.jl b/src/jlgen.jl index 06e9e0ed..c5054547 100644 --- a/src/jlgen.jl +++ b/src/jlgen.jl @@ -505,6 +505,7 @@ end # HAS_INTEGRATED_CACHE function ci_cache_populate(interp, cache, mi, min_world, max_world) if VERSION >= v"1.12.0-DEV.15" inferred_ci = CC.typeinf_ext_toplevel(interp, mi, CC.SOURCE_MODE_FORCE_SOURCE) # or SOURCE_MODE_FORCE_SOURCE_UNCACHED? + @assert inferred_ci !== nothing "Inference of $mi failed" # inference should have populated our cache wvc = WorldView(cache, min_world, max_world)