[LLVMbugs] [Bug 23026] New: Parameter register assignments wrong for struct with long doubles

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 25 16:37:42 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23026

            Bug ID: 23026
           Summary: Parameter register assignments wrong for struct with
                    long doubles
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: hfinkel at anl.gov
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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, at function
    .section    .opd,"aw", at progbits
foo1:                                   # @foo1
    .align    3
    .quad    .Lfunc_begin0
    .quad    .TOC. at 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, at function
    .section    .opd,"aw", at progbits
foo2i:                                  # @foo2i
    .align    3
    .quad    .Lfunc_begin1
    .quad    .TOC. at 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","", at 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. at 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. at 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,"", at progbits

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150325/577c9a63/attachment.html>


More information about the llvm-bugs mailing list