[PATCH] Add a dereferencable attribute

Nick Lewycky nlewycky at google.com
Thu Jul 10 15:06:08 PDT 2014


On 10 July 2014 14:13, hfinkel at anl.gov <hfinkel at anl.gov> wrote:

> Updated per Nick's comment to include an explicit size (number of bytes).
> I currently picked 12 bits for the size, I'm not sure if that is a good
> choice (I did not want to use too many bits, are there only 64 in total?).
>
> Also, I renamed the AlignAttr class to IntAttr (along with all associated
> functions) because these are now just integer-carrying attributes (not
> specifically some kind of alignment).
>
> http://reviews.llvm.org/D4449
>

"dereferencable" vs. "dereferenceable". I think LLVM is consistently using
the latter right now, your patch consistently uses the former. Please fix,
either way.

You know how we never print "readonly readnone" because instead we just
print "readnone"? (This is reflected in the API as well, querying for
"onlyReadsMemory" returns true if readnone is set and readonly isn't, or if
readonly is.) What do you think of doing this for "nonnull
dereferencable(n)"? The only gotcha is that it only works when the pointer
is in address space zero, in non-zero address spaces dereferenceable(n)
does not imply nonnull.



Files:
>   docs/LangRef.rst
>   include/llvm-c/Core.h
>   include/llvm/Bitcode/LLVMBitCodes.h
>   include/llvm/IR/Argument.h
>   include/llvm/IR/Attributes.h
>   include/llvm/IR/CallSite.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
>

          else if (Kind == Attribute::Dereferencable)
            B.addDereferencableAttr(Record[++i]);
          else
            llvm_unreachable("Unknown integer attribute type");

I'm not sure that the appropriate use of llvm_unreachable. It can be
reached with a crafted .bc file, right?


>   lib/Bitcode/Writer/BitcodeWriter.cpp
>   lib/IR/AttributeImpl.h
>   lib/IR/Attributes.cpp
>

unsigned AttributeSetNode::getDereferencableBytes() const {
  for (iterator I = begin(), E = end(); I != E; ++I)

Range-based for loop?

  lib/IR/Function.cpp
  lib/IR/Value.cpp
  test/Bitcode/attributes.ll
  test/Transforms/LICM/hoist-deref-load.ll
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140710/f50028ce/attachment.html>


More information about the llvm-commits mailing list