[PATCH] D62319: IR: add 'size <N>' attribute to 'byval' function parameters

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 07:45:15 PDT 2019


t.p.northover created this revision.
t.p.northover added reviewers: jyknight, dblaikie.
Herald added subscribers: dexonsmith, steven_wu, hiraditya, javed.absar, mcrosier, mehdi_amini.
Herald added a project: LLVM.

One of the remaining blocking issues for merging all pointer types is that `byval` parameters need some way to communicate their size other than the element type of the pointer. This patch addresses the issue by adding a `size` function attribute, only usable with `byval` that encodes the information independently.

It's mostly a pretty straightforward copy/paste of the existing `align` handling, except I decided to allow more than 16-bits of size. It should be very rare, but I have seen people pass ridiculous structs by value and the compiler should probably be able to cope.

The main other thing I found slightly questionable was whether we could reuse the existing `dereferencable` or `alloc_size` attributes. In the end I decided the semantic contortion was just slightly too high so implemented a new keyword to be maximally compatible with the `align` it will sit next to.


https://reviews.llvm.org/D62319

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Argument.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/CallSite.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Assembler/invalid-size.ll
  llvm/test/Assembler/invalid-size1.ll
  llvm/test/Assembler/invalid-size2.ll
  llvm/test/Assembler/size-param-attr.ll
  llvm/test/CodeGen/AArch64/byval-size.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62319.200973.patch
Type: text/x-patch
Size: 25034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190523/3ea16a00/attachment.bin>


More information about the llvm-commits mailing list