[LLVMdev] Setting alignment for a ByVal argument

Duncan Sands baldrick at free.fr
Tue Apr 27 05:19:06 PDT 2010

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.



More information about the llvm-dev mailing list