[LLVMbugs] [Bug 2230] New: va_copy on x86-64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Apr 16 17:29:25 PDT 2008


           Summary: va_copy on x86-64
           Product: tools
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: gohman at apple.com
                CC: llvmbugs at cs.uiuc.edu

For this testcase:

#include <stdarg.h>
void foo(va_list *a, va_list *b) {
  va_copy(*a, *b);

llvm-gcc -m64 emits this:

define void @foo([1 x %struct.__va_list_tag]* %a, [1 x %struct.__va_list_tag]*
%b) nounwind  {
        %memtmp = alloca %struct.__va_list_tag*
        %tmp1 = getelementptr [1 x %struct.__va_list_tag]* %b, i32 0, i32 0     
        store %struct.__va_list_tag* %tmp1, %struct.__va_list_tag** %memtmp
        %tmp234 = bitcast [1 x %struct.__va_list_tag]* %a to i8*
        %memtmp5 = bitcast %struct.__va_list_tag** %memtmp to i8*
        call void @llvm.va_copy( i8* %tmp234, i8* %memtmp5 )
        ret void

It's storing the second argument to a stack location, and passing the address
of that location to @llvm.va_copy instead of passing the value of the second
argument itself.

The LLVM Language Reference entry for va_copy says that
"The second argument is a pointer to a va_list element to copy from."

As it happens, LLVM codegen is currently compensating for this bug by
performing an extra load on the second argument. As a result, the llvm-gcc
compiler produces correct code, but the intermediate form is incorrect and
other frontends won't work properly.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list