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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to