[PATCH] D82962: [Alignment][NFC] Use Align for BPFAbstractMemberAccess::RecordAlignment

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 08:06:00 PDT 2020


courbet accepted this revision.
courbet added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:120
     uint32_t AccessIndex;
-    uint32_t RecordAlignment;
+    Align RecordAlignment;
     MDNode *Metadata;
----------------
I cannot convince myself that this is an NFC.  Aggregate initialization will initialize `RecordAlignment` to `0`, and there are some cases when `RecordAlignment` is not set by code (e.g. `BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall`). 

On the other hand, the only usage is
```
uint32_t MemberBitSize = MemberTy->getSizeInBits();
  uint32_t MemberBitOffset = MemberTy->getOffsetInBits();
  uint32_t AlignBits = RecordAlignment * 8;
  if (RecordAlignment > 8 || MemberBitSize > AlignBits)
    report_fatal_error("Unsupported field expression for llvm.bpf.preserve.field.info, "
                       "requiring too big alignment");
```

So it looks like `0` would always lead to a fatal error anyway, so non-zero is really not intended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82962





More information about the llvm-commits mailing list