[PATCH] [IR] Introduce a dereferenceable_xor_null(N) attribute.
Sanjoy Das
sanjoy at playingwithpointers.com
Thu Mar 26 21:56:28 PDT 2015
For context -- this was discussed on llvmdev some time ago:
http://article.gmane.org/gmane.comp.compilers.llvm.devel/82186
On Thu, Mar 26, 2015 at 9:12 PM, Sanjoy Das
<sanjoy at playingwithpointers.com> wrote:
> Hi hfinkel, rafael,
>
> If a pointer is marked as dereferenceable_xor_null(N), LLVM assumes it
> is exactly one of { null, dereferenceable(N) }. This change only
> introduces the attribute and adds a token test case for the `llvm-as` /
> `llvm-dis`. It does not hook up other parts of the optimizer to
> actually exploit the attribute -- those changes will come later.
>
> For pointers in address space 0, `dereferenceable(N)` is now exactly
> equivalent to `dereferenceable_xor_null(N)` && `nonnull`. For other
> address spaces, `dereferenceable(N)` is potentially weaker than
> `dereferenceable_xor_null(N)` && `nonnull` (since we could have a null
> `dereferenceable(N)` pointer).
>
> The motivating case for this change is Java (and other managed
> languages), where pointers are either `null` or dereferenceable up to
> some usually known-at-compile-time constant offset.
>
> http://reviews.llvm.org/D8650
>
> Files:
> docs/LangRef.rst
> include/llvm-c/Core.h
> include/llvm/Bitcode/LLVMBitCodes.h
> include/llvm/IR/Attributes.h
> include/llvm/IR/Function.h
> include/llvm/IR/Instructions.h
> lib/AsmParser/LLLexer.cpp
> lib/AsmParser/LLParser.cpp
> lib/AsmParser/LLParser.h
> lib/AsmParser/LLToken.h
> lib/Bitcode/Reader/BitcodeReader.cpp
> lib/Bitcode/Writer/BitcodeWriter.cpp
> lib/IR/AttributeImpl.h
> lib/IR/Attributes.cpp
> lib/IR/Function.cpp
> lib/IR/Instructions.cpp
> test/Assembler/deref-xor-null.ll
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list