[cfe-commits] r143596 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

Hatanaka, Akira ahatanaka at mips.com
Wed Jan 4 12:02:07 PST 2012


This is the test case.

________________________________________
From: Hatanaka, Akira
Sent: Wednesday, January 04, 2012 11:21 AM
To: Eli Friedman
Cc: cfe-commits at cs.uiuc.edu
Subject: RE: [cfe-commits] r143596 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

So I finally came up with a way to fix the alignment issue.
Please review the attached patch & test case.

The idea is to add a parameter to ABIArgInfo::getDirect that is used to set the size of a padding inserted before a byval aggregate. The test case shows padding is inserted before the first element of a 16-byte aligned byval structure when the first element is not aligned to a 16-byte boundary.

________________________________________
From: Eli Friedman [eli.friedman at gmail.com]
Sent: Monday, November 07, 2011 8:04 PM
To: Hatanaka, Akira
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: [cfe-commits] r143596 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

On Mon, Nov 7, 2011 at 7:27 PM, Hatanaka, Akira <ahatanaka at mips.com> wrote:
> Just to add to my previous email,
>
> tail call void @callee(i32 3, double %0, i64 %1, i64 %2, i64 %3) nounwind
>
> Without alignment information attached to "double %0", this is how the backend will pass arguments in registers, when the function above is lowered:
> i32 3 => 1st integer register
> double %0 => 2nd FP register
> i64 %1 => 3rd integer register
> i64 %2, i64 %3 => 4th and 5th integer register
>
> The correct way to pass arguments is the following:
> i32 3 => 1st integer register
> double %0 => 3rd FP register
> i64 %1 => 4th integer register
> i64 %2, i64 %3 => 5th and 6th integer register

As you've figured out, you can't attach alignment to scalars.  IIRC,
x86 doesn't run into this issue.  Something like "tail call void
@callee(i32 3, i32 undef, double %0, i64 %1, i64 %2, i64 %3) nounwind"
probably does what you want. I'm not entirely sure how you would
convince clang to emit that, though; it might require extending the
ABI interface a bit.

-Eli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mips64byvalarg.c
Type: text/x-c
Size: 1015 bytes
Desc: mips64byvalarg.c
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120104/7b8c6676/attachment.bin>


More information about the cfe-commits mailing list