[PATCH] Correctly Load Mixed FP-GP Variadic Arguments for x86-64

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 24 12:58:15 PDT 2014


LGTM. Just a nit, the test can be reduced juts a bit further to

struct Bar foo( __builtin_va_list ap) {
  return __builtin_va_arg(ap, struct Bar);
}

This avoid the llvm.va_start call and makes the abi issue more explicit.


On 16 June 2014 17:23, Thomas Jablin <tjablin at gmail.com> wrote:
> Please find enclosed an updated patch containing a test showing the
> difference in the generated IR.
> Tom
>
>
> On Mon, Jun 16, 2014 at 3:25 PM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>>
>> Can you write a test showing the difference is the generated IR? Look
>> at the tests i clang/test/CodeGen for examples.
>>
>> On 16 June 2014 13:46, Thomas Jablin <tjablin at gmail.com> wrote:
>> > Hi,
>> > Please find enclosed a patch to resolve PR20018. According to the x86-64
>> > ABI, structures with both floating point and integer members are split
>> > between floating-point and general purpose registers, and consecutive
>> > 32-bit
>> > floats can be packed into a single floating point register. In variadic
>> > functions, clang writes out the state of the GP registers and FP
>> > registers
>> > to different regions in memory. A bug in the TargetInfo logic is causing
>> > llvm to try to read floating point arguments from the FP region of the
>> > stack. Specifically:
>> >
>> > 02593     llvm::Value *RegLoAddr = TyLo->isFloatingPointTy() ? FPAddr :
>> > GPAddr;
>> > 02594     llvm::Value *RegHiAddr = TyLo->isFloatingPointTy() ? GPAddr :
>> > FPAddr;
>> >
>> > Are checking if TyLo is a floating point type, however, two consecutive
>> > floating point fields will be represented as an floating point vector.
>> > Consequently, the correct code should be:
>> >
>> > 02593    llvm::Value *RegLoAddr = TyLo->isFPOrFPVectorTy() ? FPAddr :
>> > GPAddr;
>> > 02594    llvm::Value *RegHiAddr = TyLo->isFPOrFPVectorTy() ? GPAddr :
>> > FPAddr;
>> >
>> > The code on line 2623 is already checking for floating point vectors
>> > appropriately. I have also attached a simple test case named gpfpTest.c.
>> > Thanks.
>> > Tom
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>
>




More information about the cfe-commits mailing list