[llvm-dev] Alignment parameter attributes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
I have a question about how to communicate alignment via function
parameters.  The IR supports an attribute specifying the alignment of a
pointer parameter:

define void @func(double* noalias align 64 %p)

This says that %p is 64-byte aligned.  Great!

Is there any way to convey the alignment of a pointer pointed to by a **
argument?  I'd like something like this:

define void @func(double* align 64 * noalias %p)

Or even this to add a noalias attribute:

define void @func(double* noalias align 64 * noalias %p)

I don't think either of these is legal today.

Has anyone else run into this need?  If so, any advice would be much
appreciated!

                  -David
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
On 01/14, Greene, David via llvm-dev wrote:

> I have a question about how to communicate alignment via function
> parameters.  The IR supports an attribute specifying the alignment of a
> pointer parameter:
>
> define void @func(double* noalias align 64 %p)
>
> This says that %p is 64-byte aligned.  Great!
>
> Is there any way to convey the alignment of a pointer pointed to by a **
> argument?  I'd like something like this:
>
> define void @func(double* align 64 * noalias %p)
>
> Or even this to add a noalias attribute:
>
> define void @func(double* noalias align 64 * noalias %p)
>
> I don't think either of these is legal today.
>
> Has anyone else run into this need?  If so, any advice would be much
> appreciated!
If you have this knowledge during code generation you can associate
align metadata to the loads from %p.

We could use a custom tag on `llvm.assume`, as an extension of
https://reviews.llvm.org/D72475, but that is not yet implemented.

Cheers,
  Johannes

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
"Doerfert, Johannes via llvm-dev" <[hidden email]> writes:

> We could use a custom tag on `llvm.assume`, as an extension of
> https://reviews.llvm.org/D72475, but that is not yet implemented.

I had thought about using llvm.assume but was wondering if there is a
better way.  Tagging the loads with metadata really seems about the same
amount of effort.  Both require major surgery to code generation.

Thanks for your help Johannes!

                  -David
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
It might be interesting to add "pointee" attributes on pointers, that is attributes that are attached to the pointee, however that requires a larger discussion.

________________________________________
From: Greene, David <[hidden email]>
Sent: Tuesday, January 14, 2020 16:23
To: Doerfert, Johannes
Cc: [hidden email]
Subject: Re: [llvm-dev] Alignment parameter attributes

"Doerfert, Johannes via llvm-dev" <[hidden email]> writes:

> We could use a custom tag on `llvm.assume`, as an extension of
> https://reviews.llvm.org/D72475, but that is not yet implemented.

I had thought about using llvm.assume but was wondering if there is a
better way.  Tagging the loads with metadata really seems about the same
amount of effort.  Both require major surgery to code generation.

Thanks for your help Johannes!

                  -David
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
"Doerfert, Johannes via llvm-dev" <[hidden email]> writes:

> It might be interesting to add "pointee" attributes on pointers, that
> is attributes that are attached to the pointee, however that requires
> a larger discussion.

For sure.  I think it could be useful but we would need more use-cases
to justify it.  I'm not sure my situation rises to the level of being a
really compelling case since there are other ways to fix this issue,
they just aren't very pleasant to implement.  :)

                        -David
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Alignment parameter attributes

Johannes Doerfert via llvm-dev
In reply to this post by Johannes Doerfert via llvm-dev
Haven't followed the discussion in detail - but just in case: pointee types aren't something you should build further reliance on as the long term plan is to remove them. (to have opaque pointer types that don't carry any information about what they point to) - in part because LLVM doesn't provide any guarantees about the type safety of pointers, etc.

On Tue, Jan 14, 2020 at 2:27 PM Doerfert, Johannes via llvm-dev <[hidden email]> wrote:
It might be interesting to add "pointee" attributes on pointers, that is attributes that are attached to the pointee, however that requires a larger discussion.

________________________________________
From: Greene, David <[hidden email]>
Sent: Tuesday, January 14, 2020 16:23
To: Doerfert, Johannes
Cc: [hidden email]
Subject: Re: [llvm-dev] Alignment parameter attributes

"Doerfert, Johannes via llvm-dev" <[hidden email]> writes:

> We could use a custom tag on `llvm.assume`, as an extension of
> https://reviews.llvm.org/D72475, but that is not yet implemented.

I had thought about using llvm.assume but was wondering if there is a
better way.  Tagging the loads with metadata really seems about the same
amount of effort.  Both require major surgery to code generation.

Thanks for your help Johannes!

                  -David
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev