Skip to content

Commit 3192299

Browse files
committed
[Julia-1.12] World age fixes. Adapt to changes made for global module names.
1 parent 408db42 commit 3192299

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

src/cleanup/julia_names.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Regex matching all global variable names which might change from one compilation
6363
!!! compat "Julia 1.11"
6464
Those global variables names only appear starting from Julia 1.11.
6565
66+
!!! compat "Julia 1.12"
67+
Those global variables may now start with `jl_` instead of `+`.
68+
6669
In LLVM IR, those variables are mentioned as such: `@"+Core.GenericMemory#14067.jit"`.
6770
In native code, they look like this: `".L+Core.GenericMemory#13985.jit"`, with maybe some
6871
`.set` and `.size` sections at the end of the code (in x86 ASM).
@@ -79,8 +82,15 @@ in `julia_pgv(ctx, cname, addr)` at [`'src/cgutils.cpp#L358'`](https://github.co
7982
which is then added a `".jit"` suffix in [`'src/aotcompile.cpp#L2064'`](https://github.com/JuliaLang/julia/blob/08e1fc0abb959ce5bd4c75b05518a41b85e4aba1/src/aotcompile.cpp#L2064)
8083
when doing code introspection.
8184
"""
82-
global_var_unique_gen_name_regex() = r"(\+[^\"\s,;\-']+)#\d+\.jit"
83-
global_var_unique_gen_name_regex(global_name) = Regex("(\\+\\Q$(global_name)\\E)#\\d+\\.jit")
85+
function global_var_unique_gen_name_regex end
86+
87+
@static if VERSION < v"1.12-"
88+
global_var_unique_gen_name_regex() = r"(\+[^\"\s,;\-']+)#\d+\.jit"
89+
global_var_unique_gen_name_regex(global_name) = Regex("(\\+\\Q$(global_name)\\E)#\\d+\\.jit")
90+
else
91+
global_var_unique_gen_name_regex() = r"((?:\+|jl_)[^\"\s,;\-']+)#\d+\.jit"
92+
global_var_unique_gen_name_regex(global_name) = Regex("((?:\\+|jl_)\\Q$(global_name)\\E)#\\d+\\.jit")
93+
end
8494

8595

8696
"""

src/get_code.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ function code_native(
6363
else
6464
src = Base.Compiler.typeinf_code(Base.Compiler.NativeInterpreter(world), mi, true)
6565
if dump_module
66-
f_str = InteractiveUtils._dump_function_native_assembly(mi, src, world, false, syntax, debuginfo, binary, raw, params)
66+
f_str = InteractiveUtils._dump_function_native_assembly(mi, src, false, syntax, debuginfo, binary, raw, params)
6767
else
68-
f_str = InteractiveUtils._dump_function_native_disassembly(mi, src, world, false, syntax, debuginfo, binary)
68+
f_str = InteractiveUtils._dump_function_native_disassembly(mi, src, false, syntax, debuginfo, binary)
6969
end
7070
end
7171

@@ -127,7 +127,7 @@ function code_llvm(
127127
else
128128
src = Base.Compiler.typeinf_code(Base.Compiler.NativeInterpreter(world), mi, true)
129129
f_str = InteractiveUtils._dump_function_llvm(
130-
mi, src, world, false, !raw, dump_module, optimize, debuginfo, params
130+
mi, src, false, !raw, dump_module, optimize, debuginfo, params
131131
)
132132
end
133133

test/cleanup.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ end
5555

5656
# jlcapi_
5757
get_cfunc_add() = @cfunction(+, Int, (Int, Int))
58-
@test occursin(r"jlcapi_\+_\d+", @io2str code_llvm(::IO, get_cfunc_add, Tuple{}))
59-
@test CDC.replace_llvm_module_name("jlcapi_+_123") == "+"
58+
if VERSION < v"1.12-"
59+
@test occursin(r"jlcapi_\+_\d+", @io2str code_llvm(::IO, get_cfunc_add, Tuple{}))
60+
@test CDC.replace_llvm_module_name("jlcapi_+_123") == "+"
61+
else
62+
# TODO: they changed how operator names work in 1.12? I don't know if this is fine or not...
63+
@test occursin(r"jlcapi_#\+_\d+", @io2str code_llvm(::IO, get_cfunc_add, Tuple{}))
64+
@test CDC.replace_llvm_module_name("jlcapi_#+_123") == "#+"
65+
end
6066

6167
# j_
6268
function test_append(a, b)
@@ -73,10 +79,16 @@ end
7379
@test CDC.replace_llvm_module_name("j_copyto!_123") == "copyto!"
7480

7581
@test occursin(CDC.global_var_unique_gen_name_regex(), test_append_llvm_ir)
76-
@test occursin(CDC.global_var_unique_gen_name_regex("Core.GenericMemory"), test_append_llvm_ir)
82+
83+
if VERSION v"1.12-"
84+
@test occursin(CDC.global_var_unique_gen_name_regex("global"), test_append_llvm_ir)
85+
else
86+
@test occursin(CDC.global_var_unique_gen_name_regex("Core.GenericMemory"), test_append_llvm_ir)
87+
end
7788

7889
@test CDC.replace_llvm_module_name("@+Core.GenericMemory#123.jit") == "@+Core.GenericMemory.jit"
7990
@test CDC.replace_llvm_module_name(".L+Core.GenericMemory#123.jit") == ".L+Core.GenericMemory.jit"
91+
@test CDC.replace_llvm_module_name(".L+Core.Array#123.jit") == ".L+Core.Array.jit"
8092
else
8193
@test occursin(CDC.function_unique_gen_name_regex(), test_append_llvm_ir)
8294
@test occursin(CDC.function_unique_gen_name_regex("_append!"), test_append_llvm_ir)

0 commit comments

Comments
 (0)