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

Thomas Jablin tjablin at gmail.com
Thu Jun 12 16:21:23 PDT 2014

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 :
02594     llvm::Value *RegHiAddr = TyLo->isFloatingPointTy() ? GPAddr :

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 :
02594    llvm::Value *RegHiAddr = TyLo->isFPOrFPVectorTy() ? GPAddr :

The code on line 2623 is already checking for floating point vectors
appropriately. I have also attached a simple test case named gpfpTest.c.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140612/a7d7ca90/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GPFP.patch
Type: text/x-patch
Size: 886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140612/a7d7ca90/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gpfpTest.c
Type: text/x-csrc
Size: 409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140612/a7d7ca90/attachment.c>

More information about the llvm-commits mailing list