This patch adds a new argument attribute nonnull. This lets LLVM get rid of certain null checks. GCC already has a nonnull attribute. Also, this would be useful in Rust since we can mark a lot of our pointers as such.
Details
Diff Detail
Event Timeline
Thanks for working on this!
When uploading a patch to phabricator, please increase the number of context lines as documented here: http://llvm.org/docs/Phabricator.html
test/Analysis/BasicAA/nonnull.ll | ||
---|---|---|
1 ↗ | (On Diff #8553) | This test is in the wrong place. You seem to be testing instcombine here, not basicaa, and so the test should be in test/Transforms/InstCombine somewhere. |
Seems pretty cool.
Is it meaningful to have a nonnull attribute on a non-pointer type? Mind outlawing that in the Verifier, and then adding a verifier test?
Your change to lib/IR/Value.cpp is wrong, a nonnull pointer is not
necessarily dereferenceable.
%a = inttoptr i32 123456 to i32*
call void @foo(i32* %a nonnull)
It's nonnull, but not dereferenceable.
Nick
Luqman Aden wrote:
Added test.CHANGE SINCE LAST DIFF
http://reviews.llvm.org/D3389?vs=8552&id=8553#tocFiles:
lib/AsmParser/LLToken.h lib/AsmParser/LLParser.cpp lib/AsmParser/LLLexer.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/IR/Function.cpp lib/IR/Attributes.cpp lib/Analysis/ValueTracking.cpp test/Bitcode/attributes.ll test/Analysis/BasicAA/nonnull.ll include/llvm/Bitcode/LLVMBitCodes.h include/llvm/IR/Attributes.h include/llvm/IR/Argument.h
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
This information could also be used in ArgPromotion::isSafeToPromoteArgument(). Its second argument, isByValOrInAlloca, is used to determine whether a pointer argument is always valid.
dotdash:
This information could also be used in ArgPromotion::isSafeToPromoteArgument(). Its second argument, isByValOrInAlloca, is used to determine whether a pointer argument is always valid.
I don't that would be valid since a nonnull pointer is not necessarily dereferenceable.