[llvm-bugs] [Bug 26162] New: Incompatible with GCC abi on Linux AArch64 for zero-sized array GNU extension

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 15 11:40:15 PST 2016


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

            Bug ID: 26162
           Summary: Incompatible with GCC abi on Linux AArch64 for
                    zero-sized array GNU extension
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yyc1992 at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code compiles differently in clang and GCC

```
struct large_ha {
    struct {
        double a[0];
    };
    double b;
    double c;
    double d;
};

struct large_ha bar(struct large_ha v)
{
    return v;
}
```

Clang treats this as a homogeneous floating-point aggregate (HFA) and pass it
in the register for both the function argument and return value (in the same
register) and therfore the function body is,

```
bar:                                    // @bar
// BB#0:
        ret
```

GCC seems to treat this as non-HFA and therefore uses `sret` for the return
value and pass the argument by reference and the code generated is,


```
bar:
        mov     x1, x0
        mov     x0, x8
        ldp     x2, x3, [x1]
        ldr     x1, [x1, 16]
        stp     x2, x3, [x8]
        str     x1, [x8, 16]
        ret
```

Giving the embedded struct a name makes no difference on either of them.

-- 
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/20160115/9d431541/attachment.html>


More information about the llvm-bugs mailing list