[LLVMbugs] [Bug 18889] New: [ABI] powerpc-darwin struct layout incorrect

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 18 14:23:59 PST 2014


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

            Bug ID: 18889
           Summary: [ABI] powerpc-darwin struct layout incorrect
           Product: libraries
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Keywords: ABI
          Severity: release blocker
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: fang at csl.cornell.edu
                CC: iains-llvm at btconnect.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Iain shared some test cases that expose some differences between struct layout
in gcc (apple's system) and clang, both with PowerPC32.  These are high
priority fixes.  


Case 0:
// "structs-0.c"
#include <stdbool.h>

struct _L {
 long long L;
} L;

struct _b {
 _Bool b;
} b;

struct _c {
 char c;
} c;

struct _s {
 short s;
} s;

struct _i {
 int i;
} i;

struct _l {
 long l;
} l;

struct _f {
 float f;
} f;

struct _d {
 double d;
} d;

struct _D {
 long double D;
} D;

#ifdef MAIN
#include <stdint.h>
#include <stdio.h>

int main (void)
{
  printf ("sizes   : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
        sizeof(_Bool), sizeof(char), sizeof(short), sizeof(int), sizeof(long), 
        sizeof(long long), sizeof(float), sizeof(double), sizeof(long double));
  printf ("aligns  : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
        __alignof__(_Bool), __alignof__(char), __alignof__(short),
        __alignof__(int), __alignof__(long), __alignof__(long long),
        __alignof__(float), __alignof__(double), __alignof__(long double));

  printf ("s-size  : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
        sizeof(b), sizeof(c), sizeof(s),
        sizeof(i), sizeof(l), sizeof(L),
        sizeof(f), sizeof(d), sizeof(D));
  printf ("s-align : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
        __alignof__(b), __alignof__(c), __alignof__(s),
        __alignof__(i), __alignof__(l), __alignof__(L),
        __alignof__(f), __alignof__(d), __alignof__(D));

  return 0;
}

#endif


----
differences:
--- structs-0.gcc-out   2014-02-18 13:43:45.000000000 -0800
+++ structs-0.clang-out 2014-02-18 13:43:45.000000000 -0800
@@ -1,4 +1,4 @@
 sizes   : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
 aligns  : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
 s-size  : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
-s-align : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
+s-align : b 4 c 1 s 2 i 4 l 4 ll 4 f 4 d 8 ld 16


case 1:
// "structs-1.c"
struct _cd {
 char c;
 double d;
} cd;

struct _dc {
 double d;
 char c;
} dc;


struct _cL {
 char c;
 long long L;
} cL;


struct _Lc {
 long long L;
 char c;
} Lc;

struct _cScd {
 char c;
 struct _cd Scd;
} cScd;

struct _cSdc {
 char c;
 struct _dc Sdc;
} cSdc;

struct _cScL {
 char c;
 struct _cL ScL;
} cScL;

struct _cSLc {
 char c;
 struct _Lc SLc;
} cSLc;

#ifdef MAIN
#include <stdint.h>
#include <stdio.h>

int main (void)
{
  printf ("s-size  : cd %ld dc %ld cL %ld Lc %ld cScd %ld cSdc %ld cScL %ld
cSLc %ld\n",
        sizeof(cd), sizeof(dc), sizeof(cL), sizeof(Lc),
        sizeof(cScd), sizeof(cSdc), sizeof(cScL), sizeof(cSLc));
  printf ("s-align : cd %ld dc %ld cL %ld Lc %ld cScd %ld cSdc %ld cScL %ld
cSLc %ld\n",
        __alignof__(cd), __alignof__(dc), __alignof__(cL), __alignof__(Lc),
        __alignof__(cScd), __alignof__(cSdc), __alignof__(cScL),
__alignof__(cSLc));

  return 0;
}

#endif

----
differences:
--- structs-1.gcc-out   2014-02-18 13:43:45.000000000 -0800
+++ structs-1.clang-out 2014-02-18 13:43:45.000000000 -0800
@@ -1,2 +1,2 @@
-s-size  : cd 12 dc 16 cL 12 Lc 16 cScd 16 cSdc 20 cScL 16 cSLc 20
-s-align : cd 4 dc 8 cL 4 Lc 8 cScd 4 cSdc 4 cScL 4 cSLc 4
+s-size  : cd 16 dc 16 cL 12 Lc 12 cScd 24 cSdc 24 cScL 16 cSLc 16
+s-align : cd 8 dc 8 cL 4 Lc 4 cScd 8 cSdc 8 cScL 4 cSLc 4

--------------------
Iain has some patches that address this.  I plan to help convert these test
cases to use dump-record-layout and FileCheck.

-- 
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/20140218/929b67f0/attachment.html>


More information about the llvm-bugs mailing list