-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix compile time regression for null ptr comparisons #59259
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be an assert? It appears we only call this when the frontend IR put a check here mandating that the bit pattern be all zeros.
There's a case which I haven't tracked down too well here but that we emit a null check on an alloca. Where we as frontend will comply with AMDGPU and emit the alloca on the correct addresspace |
JuliaGPU/AMDGPU.jl#780 i.e here. I think LLVM can and does fold those away for normal pointers but not here |
For code that emits those null checks see function foo(C, A, ta)
@inbounds for i in eachindex(C)
x = ta == 0 ? A[1] : (ta == 1 ? A[1] : A[1])
C[i] = x
end
nothing
end
@code_llvm optimize=false foo(zeros(ComplexF64,1,1), ones(ComplexF64, 1), 1) There are at least 3 null checks of allocas here |
Ah okay right, we use that for |
The issue is LLVM hard codes null to 0, which is not what C says. And AMD is the only target that actually exposes that. The actual null is never a valid address, which is why in C amdgpu clang will introduce the same thing we're doing here. |
…ion for null ptr comparisons") to Julia 1.11.x (#59446) Backports #59259 to 1.11 (cherry picked from commit 920df7a). For more details, see #59445 (comment). Targets `backports-release-1.11` (#59336). --------- Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com>
Fixes the compile time regression in #59134 (does not address the performance regression that should be tracked and bisected)