Yes, I see the load is 8-byte aligned in the bit code.<br><br>My question was, assuming that arguments requiring double word alignment have to be passed in even/odd registers, how does the backend know that %0 has to be passed in register r2 and r3?<br>
<br><b>tail call arm_aapcscc  void (i32, ...)* @foo0(i32 1, [2 x i32] %0) 
nounwindt<br></b><br>It doesn't seem that ARM backend can figure out that "[2 x i32] %0" was 
originally a structure consisting of a single double field. When I run llc, it looks like "%0" is being passed in register r1 and r2.<br>
<br><b>$ llc vararg1-main.ll -o -<br><br>ldr     r0, .LCPI0_0<br>ldm     r0, {r1, r2}<br><br>.LCPI0_0:<br>        .long   .Lmain.s0<br>...<br>.Lmain.s0:<br>        .long   0                       @ double 2.000000e+00<br>
<br></b><br>I am running tests to see if llc targeting mips can correctly compile a bitcode file generated by clang-arm.<br>One of the tests is failing, and I was wondering whether this could be a bug in arm-specific part of clang.<br>
<br>The attached files are the tests (reduced test case) I used.<br><br><div class="gmail_quote">On Mon, Aug 6, 2012 at 5:52 PM, Bill Wendling <span dir="ltr"><<a href="mailto:wendling@apple.com" target="_blank">wendling@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On Aug 6, 2012, at 3:21 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>> wrote:<br>
<br>
> When I compile this program<br>
><br>
> $ cat vararg1-main.c<br>
><br>
> typedef struct {<br>
>   double d;<br>
> } S0;<br>
><br>
> S0 g1;<br>
><br>
> void foo0(int a, ...);<br>
><br>
> int main(int argc, char **argv) {<br>
>   S0 s0 = { 2.0 };<br>
><br>
>   foo0(1, s0);<br>
><br>
>   printf("%f\n", g1.d);<br>
><br>
>   return 0;<br>
> }<br>
><br>
> with this command,<br>
><br>
> $ clang  -target arm-none-linux-gnueabi-gcc  -ccc-clang-archs armv7  -emit-llvm vararg1-main.c  -S -o vararg1-main.ll -O3<br>
><br>
> I get this bitcode.<br>
><br>
> $ cat vararg1-main.ll<br>
><br>
> define arm_aapcscc i32 @main(i32 %argc, i8** nocapture %argv) nounwind {<br>
> entry:<br>
>   %0 = load [2 x i32]* bitcast (%struct.S0* @main.s0 to [2 x i32]*), align 8<br>
>   tail call arm_aapcscc  void (i32, ...)* @foo0(i32 1, [2 x i32] %0) nounwind<br>
>   %1 = load double* getelementptr inbounds (%struct.S0* @g1, i32 0, i32 0), align 8, !tbaa !0<br>
>   %call = tail call arm_aapcscc  i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double %1) nounwind<br>
>   ret i32 0<br>
> }<br>
><br>
> My understanding is that ARM eabi requires that structure S0 be 8-byte aligned when it is passed to function foo0, i.e. it should be passed in register r2 and r3.<br>
><br>
> Is there anything in the call to foo0 that informs the backend that %0 should be 8-byte aligned?<br>
><br>
>   tail call arm_aapcscc  void (i32, ...)* @foo0(i32 1, [2 x i32] %0) nounwind<br>
><br>
</div></div>The load is 8-byte aligned.<br>
<span class="HOEnZb"><font color="#888888"><br>
-bw<br>
<br>
</font></span></blockquote></div><br>