<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Parameter register assignments wrong for struct with long doubles"
   href="https://llvm.org/bugs/show_bug.cgi?id=23026">23026</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Parameter register assignments wrong for struct with long doubles
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hfinkel@anl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given this program:

$ cat /tmp/ld1.c
struct ld2 { long double x[2]; };
long double foo1(int n, struct ld2 v) {
  return v.x[0];
}

long double foo2i(int n, struct ld2 v) {
  return v.x[1];
}

There is a mismatch as demonstrated below. gcc believes that v.x[0] is passed
in r4/r5, while clang believes that they reside in r5/r6. The registers used to
access v.x[1] are also off by one. Unfortunately, we're not self-consistent
here either (when we call these functions, we use the same registers as gcc to
pass in the values -- resulting is raw miscompiles ABI issues aside).

$ clang -O3 -S -o - /tmp/ld1.c 
    .text
    .file    "/tmp/ld1.c"
    .globl    foo1
    .align    2
    .type    foo1,@function
    .section    .opd,"aw",@progbits
foo1:                                   # @foo1
    .align    3
    .quad    .Lfunc_begin0
    .quad    .TOC.@tocbase
    .quad    0
    .text
.Lfunc_begin0:
# BB#0:                                 # %entry
    std 5, -24(1)
    std 6, -16(1)
    nop
    lfd 1, -24(1)
    lfd 2, -16(1)
    blr
    .long    0
    .quad    0
.Lfunc_end0:
    .size    foo1, .Lfunc_end0-.Lfunc_begin0

    .globl    foo2i
    .align    2
    .type    foo2i,@function
    .section    .opd,"aw",@progbits
foo2i:                                  # @foo2i
    .align    3
    .quad    .Lfunc_begin1
    .quad    .TOC.@tocbase
    .quad    0
    .text
.Lfunc_begin1:
# BB#0:                                 # %entry
    std 7, -24(1)
    std 8, -16(1)
    nop
    lfd 1, -24(1)
    lfd 2, -16(1)
    blr
    .long    0
    .quad    0
.Lfunc_end1:
    .size    foo2i, .Lfunc_end1-.Lfunc_begin1


    .ident    "clang version 3.7.0 (trunk 232956) (llvm/trunk 232962)"
    .section    ".note.GNU-stack","",@progbits

$ gcc -O3 -S -o - /tmp/ld1.c 
    .file    "ld1.c"
    .section    ".toc","aw"
    .section    ".text"
    .align 2
    .p2align 4,,15
    .globl foo1
    .section    ".opd","aw"
    .align 3
foo1:
    .quad    .L.foo1,.TOC.@tocbase
    .previous
    .type    foo1, @function
.L.foo1:
    std 4,-32(1)
    std 5,-24(1)
    lfd 1,-32(1)
    lfd 2,-24(1)
    blr
    .long 0
    .byte 0,0,0,0,0,0,0,0
    .size    foo1,.-.L.foo1
    .align 2
    .p2align 4,,15
    .globl foo2i
    .section    ".opd","aw"
    .align 3
foo2i:
    .quad    .L.foo2i,.TOC.@tocbase
    .previous
    .type    foo2i, @function
.L.foo2i:
    std 6,-16(1)
    std 7,-8(1)
    lfd 1,-16(1)
    lfd 2,-8(1)
    blr
    .long 0
    .byte 0,0,0,0,0,0,0,0
    .size    foo2i,.-.L.foo2i
    .ident    "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-4)"
    .section    .note.GNU-stack,"",@progbits</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>