JuliaLang / JuliaLang/AllocCheck.jl
`jl_get_builtin_fptr` not handled correctly for call resolution
- Dominant language
- Julia
- Stars
- 255
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
```julia
julia> foo() = Core.current_scope()
foo (generic function with 1 method)
julia> @code_llvm foo()
; Function Signature: foo()
; @ REPL[3]:1 within `foo`
define nonnull ptr @julia_foo_2954() #0 {
top:
%0 = call ptr @jl_get_builtin_fptr(ptr nonnull @"+Core.#current_scope#2956.jit")
%Builtin_ret = call nonnull ptr %0(ptr nonnull @"jl_global#2957.jit", ptr null, i32 0)
ret ptr %Builtin_ret
}
julia> check_allocs(foo, (); ignore_throw = false)
2-element Vector{Any}:
Allocating runtime call to "jl_get_builtin_fptr" in ./REPL[3]:1
| (source not available)
Stacktrace:
[1] foo()
@ Main ./REPL[3]:1
Dynamic dispatch in ./REPL[3]:1
| (source not available)
Stacktrace:
[1] foo()
@ Main ./REPL[3]:1
```
This should be a single runtime call (and it's also not allocating).
As part of fixing this, we should probably add an `UnknownRuntimeFunction` error type. That way we don't imply something is allocating when really we have an unresolved runtime call.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the `foo() = Core.current_scope()` example with `@code_llvm` and `check_allocs(foo, (); ignore_throw = false)`. Trace how `jl_get_builtin_fptr` is handled during call resolution. Done means the output reports one non-allocating runtime call and uses `UnknownRuntimeFunction` rather than implying allocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100