[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type
Hal Finkel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 15:34:52 PDT 2017
hfinkel added inline comments.
================
Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:411
+ // component so as it can be accessed directly with lower cost.
+ auto betterBeSingleFieldRun = [&](RecordDecl::field_iterator Field) {
+ if (!Types.getCodeGenOpts().FineGrainedBitfieldAccesses)
----------------
betterBeSingleFieldRun -> IsBetterAsSingleFieldRun
================
Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:444
// Add bitfields to the run as long as they qualify.
- if (Field != FieldEnd && Field->getBitWidthValue(Context) != 0 &&
- Tail == getFieldBitOffset(*Field)) {
- Tail += Field->getBitWidthValue(Context);
- ++Field;
- continue;
+ if (Field != FieldEnd && !SingleFieldRun) {
+ SingleFieldRun = betterBeSingleFieldRun(Field);
----------------
The logic here is not obvious. Can you please add a comment. SingleFieldRun here is only not equal to `betterBeSingleFieldRun(Field)` if we've skipped 0-length bitfields, right? Please explain what's going on and also please make sure there's a test case.
Repository:
rL LLVM
https://reviews.llvm.org/D36562
More information about the llvm-commits
mailing list