[PATCH] D64258: [InferFuncAttributes] extend 'dereferenceable' attribute based on loads
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 11:17:43 PDT 2019
spatel added a comment.
In D64258#1578820 <https://reviews.llvm.org/D64258#1578820>, @jfb wrote:
> Right now the control flow isn't clever, but I wonder if, as this analysis becomes more powerful, it'll have to act differently when `-fno-delete-null-pointer-checks` is specified? Is there a simple test that you can add to make sure null pointer checks don't cause false assumptions whenever this optimization becomes smarter?
I hadn't seen that flag before. In IR we have this translation of the minimal test in clang/test/CodeGen/nonnull.c:
define void @foo(i32* nocapture dereferenceable(4) %x) #0 {
store i32 0, i32* %x, align 4, !tbaa !3
ret void
}
attributes #0 = { ... "null-pointer-is-valid"="true" ... }
This pass/patch doesn't act on the dereferenceable attribute; it just adds it. So some other pass would be at risk if it tries a transform based on "dereferenceable" without checking the "null-pointer-is-valid" function attribute or "nonnull" argument attribute? Argument::hasNonNullAttr() seems safe.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64258/new/
https://reviews.llvm.org/D64258
More information about the llvm-commits
mailing list