[PATCH] D79155: [CodeGen] Increase applicability of ffine-grained-bitfield-accesses for targets with limited native integer widths

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 10:41:10 PDT 2020


efriedma added a comment.

The -ffine-grained-bitfield-accesses seems to generate weird results in certain cases.  For example, on x86 we generate an unaligned load in the following example.

  struct S  { long c : 8; long z: 24; long : 0; };
  struct S s;
  int f() { return s.c+s.z; }

I guess that's not really an issue with this patch specifically, though; the general algorithm is just sort of weird.



================
Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:414
   auto IsBetterAsSingleFieldRun = [&](uint64_t OffsetInRecord,
                                       uint64_t StartBitOffset) {
     if (!Types.getCodeGenOpts().FineGrainedBitfieldAccesses)
----------------
StartBitOffset is the offset in bits of the beginning of the current run, the comment above explains that.  It's not obvious what OffsetInRecord is; I guess it's the size in bits of the current run?  The name isn't really intuitive.

This patch seems reasonable; you want to allow any legal integer, and any smaller type that can probably be naturally loaded and stored.


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

https://reviews.llvm.org/D79155





More information about the cfe-commits mailing list