[LLVMdev] Setting alignment for a ByVal argument

Arushi Aggarwal arushi987 at gmail.com
Tue Apr 27 07:29:19 PDT 2010


Hi,
Thanks for the help. I tried this out, but on x86_64 and with llvm 2.6
and llvm-gcc 4.2.1, I dont seem to get an aligned variable.


This is the function definition that I have

define internal fastcc void @walksub(%struct.hgstruct* noalias
nocapture sret %agg.result, %struct.node* %p, double %dsq,
%struct.hgstruct* byval align 64 %hg, i32 %level) nounwind {

And these are the call sites,

call fastcc void @walksub(%struct.hgstruct* noalias sret %2,
%struct.node* %tmp399, double %tmp398, %struct.hgstruct* byval align
64 %1, i32 0) nounwind

 call fastcc void @walksub(%struct.hgstruct* notcc void
@walksub(%struct.hgstruct* noalias sret %2, %struct.node* %tmp399,
double %tmp398, %struct.hgstruct* byval align 64 %1, i32 0) nounwind

The value that I get for %hg, is 0x7fffe0e34a20 which is not aligned
to 64 byte boundary.

Any pointers on where I could be wrong?

Thanks,
Arushi



On Tue, Apr 27, 2010 at 7:19 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Arushi,
>
>> If I want a particular alignment on a ByVal argument, should I specify
>> it as a function attribute, or should I also add the attribute to
>> every callsite that calls that function.
>
> in theory you should do both.  For example, if the call is an indirect call
> (i.e. to a function pointer where the function is not known) then it should
> be clear that you need to put the attribute on the callsite.  Likewise, when
> code is being generated for the function, there is only one place where the
> code generators can find out what alignment the incoming argument has: the
> attribute on the function argument.  Hopefully these examples show why you
> should put it both on the function and any call sites.  That said, if you
> put it only on the function the code generators are usually friendly to you
> and will understand that you meant to have it on call sites too.  But if I
> were you I wouldn't rely on this.
>
> Ciao,
>
> Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list