[PATCH] D117921: Attributes: add a new allocalign() attribute

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 07:56:54 PST 2022


nikic added a comment.

In D117921#3269526 <https://reviews.llvm.org/D117921#3269526>, @reames wrote:

> In D117921#3269497 <https://reviews.llvm.org/D117921#3269497>, @durin42 wrote:
>
>> In D117921#3262394 <https://reviews.llvm.org/D117921#3262394>, @nikic wrote:
>>
>>> Might it make more sense to implement this as an argument attribute? Would be a bit simpler I think, and I don't really see a disadvantage.
>>
>> I don't have any idea. @reames any opinion? I confess I'm not sure what this means for me.
>
> I don't see anyway with argument align attributes to express the alignment of the return value of the call.  Specifically, the fact this is trying to express is "the returned pointer has at least the alignment of the integer param X".

To clarify, what I mean is:

  ; Instead of
  declare i8* @aligned_alloc(i64, i64) allocalign(1)
  ; You do
  declare i8* @aligned_alloc(i64, i64 allocalign)

That is, the `allocalign` attribute indicates that the value provided to this parameter will the alignment of the return value. The semantics would be the same as with the return attribute, you just don't need to deal with integer attributes.

If we do want to use the function attribute, I think it should be possible to support proper zero values for integer attributes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117921/new/

https://reviews.llvm.org/D117921



More information about the llvm-commits mailing list