From 3697135dac208b1bcbeb1ed66f367a261afefb9a Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sun, 23 Jun 2024 21:42:46 -0400 Subject: [PATCH] tell the serializer to not cache code instances originating from Enzyme --- src/compiler/interpreter.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/interpreter.jl b/src/compiler/interpreter.jl index e1652c5895..cd231abb66 100644 --- a/src/compiler/interpreter.jl +++ b/src/compiler/interpreter.jl @@ -68,6 +68,19 @@ else Core.Compiler.code_cache(interp::EnzymeInterpreter) = WorldView(interp.code_cache, interp.world) end +@static if HAS_INTEGRATED_CACHE + function CC.CodeInstance(interp::EnzymeInterpreter, result::CC.InferenceResult, + valid_worlds::CC.WorldRange) + ci = @invoke CC.CodeInstance(interp::CC.AbstractInterpreter, result::CC.InferenceResult, + valid_worlds::CC.WorldRange) + + # FIXME: Enzyme embeds global pointers and other fun things directly + # So forbid the caching of the results. + ci.relocatability = 0x0 + return ci + end +end + # No need to do any locking since we're not putting our results into the runtime cache Core.Compiler.lock_mi_inference(interp::EnzymeInterpreter, mi::MethodInstance) = nothing Core.Compiler.unlock_mi_inference(interp::EnzymeInterpreter, mi::MethodInstance) = nothing