[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

Sean Fertile via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 5 11:45:20 PDT 2020


sfertile added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1643
+      } else {
+        // Handle AIX oversized Long Long bitfield under 32 bit compile mode.
+        if (StorageUnitSize > 32 &&
----------------
I get different results for using a long long bitfield, and using an enum with an underlying long long type:


```
struct S {
    unsigned long long  field : 32;
};

extern "C" int printf(const char*, ...);

int main(void) {
    printf("%lu %lu\n", sizeof(struct S), alignof(struct S));
}

```
```
*** Dumping AST Record Layout
         0 | struct S
    0:0-31 |   unsigned long long field
           | [sizeof=4, dsize=4, align=4, preferredalign=4,
           |  nvsize=4, nvalign=4, preferrednvalign=4]
```
__________________________________________________________________________

```
enum e : unsigned long long { E = 1 };

struct S {
    enum e field : 32;
};

extern "C" int printf(const char*, ...);

int main(void) {
    printf("%lu %lu\n", sizeof(struct S), alignof(struct S));
}
```

```
*** Dumping AST Record Layout
         0 | struct S
    0:0-31 |   enum e field
           | [sizeof=8, dsize=8, align=8, preferredalign=8,
           |  nvsize=8, nvalign=8, preferrednvalign=8]
```
Shouldn't we be truncating the size/align of the enum typed bitfield as well?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87029/new/

https://reviews.llvm.org/D87029



More information about the cfe-commits mailing list