FluxML / IRTools.jl

Mike's Little Intermediate Representation
MIT License
111 stars 35 forks source link

Adjustment needed for Julia 1.8 #91

Closed martinholters closed 2 years ago

martinholters commented 2 years ago

Noticed in https://github.com/JuliaLang/julia/issues/43023: Since v1.8.0-DEV.267, the nargs argument of replace_code_newstyle! has changed its semantics, being offset by one. I.e. it now requires

diff --git a/src/reflection/utils.jl b/src/reflection/utils.jl
index f5dc511..66bacf6 100644
--- a/src/reflection/utils.jl
+++ b/src/reflection/utils.jl
@@ -134,7 +134,7 @@ function splicearg!(ir::IR)
 end

 function update!(ci::CodeInfo, ir::Core.Compiler.IRCode)
-  Core.Compiler.replace_code_newstyle!(ci, ir, length(ir.argtypes)-1)
+  Core.Compiler.replace_code_newstyle!(ci, ir, length(ir.argtypes))
   ci.inferred = false
   ci.ssavaluetypes = length(ci.code)
   slots!(ci)

(That obviously needs to be put inside an if VERSION check.)

simeonschaub commented 2 years ago

Nice catch, thank you so much for figuring this out!