[PATCH] D100397: Add alignment argument to the byval attribute (prototype)

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 10:42:00 PDT 2021


chill created this revision.
Herald added subscribers: dexonsmith, jdoerfert, hiraditya.
chill requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

*This is a DRAFT*

Problem statement:

We have up to three relevant alignment properties for a parameter:

- the alignment of the parameter itself (if it happens to be passed in memory)
- if it's a pointer, the actual alignment of the pointed to memory (as an optimisation aid)
- if it's a `byval` or a `byref` argument, the minimum alignment of the storage, allocated

for the original argument value (ABI affecting).

For non-pointer arguments `alignstack(N)` gives stack slot alignment.
For pointer arguments, we retain that use of `alignstack(N)` and also
have `align(M)` to give the actual alignment of the contained pointer.

Now when we add `byval` or `byref` to the above, there is no attribute
left to give the alignment of the allocated memory. We thought of
using `alignstack(N)`, but that would leave us without a way to
specify the pointer alignment itself.

Proposed solution:

Extend the `byval(Ty)` attribute to `byval(Ty [, Align])` (same for
byref` and `preallocated`).

(Most of the attributes take zero or one parameters, but there's a
precedent with `allocsize(<EltSizeParam>[, <NumEltsParam>])`)

So we end up with :

- `align(N)` for pointer content
- `stackalign(N)` for the minimum alignment for of the actual argument, if it ends up in memory
- `byval(Ty[, N])` and `byref(Ty[, N])` for the original argument value

This patch is the prototype implementation, which changes only `byval`.


https://reviews.llvm.org/D100397

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Argument.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Utils/ValueMapper.cpp
  llvm/unittests/IR/AttributesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100397.337201.patch
Type: text/x-patch
Size: 45130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/5288a289/attachment-0001.bin>


More information about the llvm-commits mailing list