<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 4:14 PM, Ulrich Weigand <span dir="ltr"><<a href="mailto:Ulrich.Weigand@de.ibm.com" target="_blank">Ulrich.Weigand@de.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote on 28.02.2015 00:41:39:<br>
<span class=""><br>
> and so we always get the alignment correct, because it is the<br>
> alignment if 'i128' (which is 16). To digress slightly, I'm now<br>
> somewhat concerned that this works more-or-less by accident (because<br>
> DataLayout only defaults to giving natural alignment to vector<br>
> types, for integers we normally just take the largest integer<br>
> alignment specified, which would be 8 in this case, and for arrays<br>
> we take the alignment of the element type) but all of the<br>
> temporaries have 16 byte alignment, and so it happens to do the<br>
> right thing (Uli implemented this, so I'm cc'ing him here).<br>
<br>
</span>So the way I intended this to work is that clang specifies the<br>
expected alignment in the argument save area by the *size* of<br>
the array element type (i.e. aggregates that require 8-byte<br>
alignment are passed as arrays of i64, and aggregates that<br>
require 16-byte alignment as passed as arrays of i128).<br>
<br>
In LLVM we respect that request by looking at the *size* of the<br>
array element type in CalculateStackSlotAlignment:<br>
<br>
  // Array members are always packed to their original alignment.<br>
  if (Flags.isInConsecutiveRegs()) {<br>
    // If the array member was split into multiple registers, the first<br>
    // needs to be aligned to the size of the full type.  (Except for<br>
    // ppcf128, which is only aligned as its f64 components.)<br>
    if (Flags.isSplit() && OrigVT != MVT::ppcf128)<br>
      Align = OrigVT.getStoreSize();<br>
    else<br>
      Align = ArgVT.getStoreSize();<br>
  }<br>
<br>
The important bit is the "OrigVT.getStoreSize" here, which will<br>
be 128 for an array of i128.<br>
<br>
This may be a bit nonintuitive, but it was the only way I found to<br>
pass alignment information from clang to LLVM if I didn't want to<br>
use ByVal.<br></blockquote><div><br>Why did you want to avoid byval? (not suggesting it's wrong, just curious)<br><br>Also, I'm only interested in the byval case - as that's where we have a pointer type that we depend on the pointee type, which I'm working to remove.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I did extensive testing (in particular, using GCC's foreign compiler<br>
ABI test suite to make sure GCC and LLVM are interoperable), so I<br>
don't think it works just by accident :-)<br>
<br>
Bye,<br>
Ulrich<br>
<br>
</blockquote></div><br></div></div>