-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected allocation in Julia 1.9/1.10 #49241
Comments
ref #47371 |
Looks like we are failing to optimize the getproperty call when inlining
|
(note that this was explicitly the goal of #47371, but that result seems a bit questionable in this context, since it means we may get much worse IR after the inlining pass if constant-prop was attempted, since running that now blocks inlining) |
I looked into this, but couldn't reproduce the regression on current master with the posted reproducer. |
Hi, thanks
|
Hi,
struct S
a::Vector{Int}
end
function f(a::S)::Int
isempty(a.a) && return 1
return error("we")
end
function g()
t=S(Int[])
@allocated f(t)
end
function g()
t=i
@allocated f(t)
end; g()
16
function g(t=i)
@allocated f(t)
end; g()
0 thanks |
Note that a workaround is using a getter for the struct S
a::Vector{Int}
end
const i = S(Int[])
g(a::S) = a.a
function f(a::S)::Int
isempty(g(a)) && return 1
error("we")
end
@allocated f(i)
@allocated f(i) # zero These issues seem possibly related: #49697 #50073 #50317 Also discussed on Discourse: https://discourse.julialang.org/t/indexing-on-a-pseudo-dimension/101119/10 |
This is fixed by #50444 |
The code below does not allocate in Julia 1.8, but it allocates 16 bytes in Julia 1.9 and 48 in Julia 1.10.
The text was updated successfully, but these errors were encountered: