Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

va_arg fails with __int128 #19908

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR19909
Status NEW
Importance P normal
Reported by Nenad Vukicevic (nenad@intrepid.com)
Reported on 2014-05-31 17:58:27 -0700
Last modified on 2019-12-12 06:44:50 -0800
Version trunk
Hardware All All
CC gary@intrepid.com, llvm-bugs@lists.llvm.org, nenad@intrepid.com, tstellar@redhat.com
Fixed by commit(s)
Attachments va_arg_128.c (1416 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 12583
Demonstrate __int128 va_arg failure

The attached example fails on Clang/LLVM trunk (or 3.4 or Apple 3.4) and passes
when compiled with gcc 4.8.2.  The code simple tries to pass multiple __int128
after two ints and a pointer.  I debugged it a bit and it seems that the
"overflow_arg_area" pointer in va_list is wrong by 8 bytes, which might
indicate some alignment problem.

I also checked how __int128 is passed to the function.  It seems that Clang is
capable of splitting the __int128 where lower part is passed in a register and
upper part on the stack.  GCC does not split __int128 if it does not have 2
registers available.  This might explain the wrong 8 bytes offset for the
"overflow_arg_area" as va_start does not adjust for the split register.
Quuxplusone commented 10 years ago

Attached va_arg_128.c (1416 bytes, application/octet-stream): Demonstrate __int128 va_arg failure