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
invalid bitcast->gep inbounds #42846
Comments
No idea if this is the best fix, but it's the simplest: |
Looking at the changed tests, I think it looks ok. Another easy-ish optimization is to keep inbounds if gep has only one use and the user is a memory access that is guaranteed to dereference the memory. Dereferencing a poison value or a OOB pointer doesn't really matter. |
|
Agreed.
Agreed, especially since you have to propagate dereferenceability backwards from a potential access. See https://reviews.llvm.org/D65402 :) |
https://reviews.llvm.org/rL373847 There's an open question (for me at least) about the semantics of a null pointer in a non-default address space, so we probably need to answer that before closing this bug report. |
That's a good point. There's a bit of confusion around that in multiple places in LLVM. So while null in AS=0 is in bounds, null in AS != 0 isn't necessarily. Actually I don't even think we should have a null constant in AS != 0 because it just creates confusion; it's not a special value. |
I agree with that assessment, it matches my understanding. |
Extended Description
See below the invalid transformation of a bitcast to a gep inbounds. The input to the bitcast is a function argument, which could be out-of-bounds.
llvm/test/Transforms/InstCombine/cast.ll
define [4 x float]* @test27([9 x [4 x float]]* %A) {
; CHECK-NEXT: [[C:%.]] = getelementptr inbounds [9 x [4 x float]], [9 x [4 x float]] [[A:%.*]], i64 0, i64 0
%c = bitcast [9 x [4 x float]]* %A to [4 x float]*
ret [4 x float]* %c
}
The text was updated successfully, but these errors were encountered: