[LLVMbugs] [Bug 7742] New: Aggregate passed in wrong register on x86-64 Darwin/Linux.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 29 01:56:39 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7742

           Summary: Aggregate passed in wrong register on x86-64
                    Darwin/Linux.
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: tilmann.scheller at googlemail.com
                CC: llvmbugs at cs.uiuc.edu


Clang generates wrong LLVM IR for the following C++ code which leads to wrong
machine code being generated:

struct s2 {
  float a[2];
};

class c2 : public s2 {
public:
c2() { a[0] = 1.5; a[1] = 3.0; }
};

c2 foo() { return c2(); }

In foo() the c2 object is passed in %rax instead of %xmm0. This bug only
affects clang, proper IR is being generated by llvm-gcc.

The bug affects both x86-64 Darwin and Linux.

clang:
_Z3foov:
.Leh_func_begin1:
    pushq    %rbp
.Llabel1:
    movq    %rsp, %rbp
.Llabel2:
    movabsq    $4629700418006417408, %rax
    popq    %rbp
    ret
    .size    _Z3foov, .-_Z3foov
.Leh_func_end1:

llvm-gcc:
.LCPI1_0:
    .quad    4629700418006417408
_Z3foov:
.Leh_func_begin1:
    movsd    .LCPI1_0(%rip), %xmm0
    ret
    .size    _Z3foov, .-_Z3foov

gcc 4.5:
_Z3foov:
.LFB6:
    movq    .LC2(%rip), %xmm0
    ret
.LC2:
    .quad    4629700418006417408


clang IR:
; ModuleID = 'float2.cpp'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"

define i64 @_Z3foov() nounwind readnone {
entry:
  ret i64 4629700418006417408
}

llvm-gcc IR:
; ModuleID = 'float2.cpp'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"

%0 = type { double }

define %0 @_Z3foov() nounwind readnone {
entry:
  %mrv2 = insertvalue %0 undef, double 0x404000003FC00000, 0 ; <%0> [#uses=1]
  ret %0 %mrv2
}

-- 
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