How to get lowered names of functions with kwargs to precompile

Hi!

I have a lot of functions in a package that has keywords arguments and I want to precompile them. However, I am not sure how can I get the lowered name. For example:

julia> function teste(::Val{:a}; b = 1, c = 2)
       b+c
       end
teste (generic function with 1 method)

julia> function teste(::Val{:b}; d = 1, e = 2)
       d-e
       end
teste (generic function with 2 methods)

julia> @code_lowered teste(Val(:a))
CodeInfo(
1 ─ %1 = Main.:(var"#teste#4")(1, 2, #self#, @_2)
└──      return %1
)

julia> @code_lowered teste(Val(:b))
CodeInfo(
1 ─ %1 = Main.:(var"#teste#5")(1, 2, #self#, @_2)
└──      return %1
)

Is there any function that returns me the name Main.:(var"#teste#5")? I tried to precompile the functions using the call in Core.kwfunc, but it is not enough.

I found a method to do this here:

https://github.com/juliamatlab/MatLang/blob/master/deps/SnoopCompile/precompile/apple/1.4/precompile_MatLang.jl

1 Like