[Bitfield] Add an option to access bitfield in a fine-grained manner.
authorWei Mi <wmi@google.com>
Mon, 16 Oct 2017 16:50:27 +0000 (16:50 +0000)
committerWei Mi <wmi@google.com>
Mon, 16 Oct 2017 16:50:27 +0000 (16:50 +0000)
commit9b3d6272800a2390eebfb9f3cd9d33523908d553
tree91dbd39836509c8fd1cbafdcddc4380d797ab3f4
parente8c1a54c07b7594e4057c76a57cadbcb0b1544a3
[Bitfield] Add an option to access bitfield in a fine-grained manner.

Currently all the consecutive bitfields are wrapped as a large integer unless there is unamed zero sized bitfield in between. The patch provides an alternative manner which makes the bitfield to be accessed as separate memory location if it has legal integer width and is naturally aligned. Such separate bitfield may split the original consecutive bitfields into subgroups of consecutive bitfields, and each subgroup will be wrapped as an integer. Now This is all controlled by an option -ffine-grained-bitfield-accesses. The alternative of bitfield access manner can improve the access efficiency of those bitfields with legal width and being aligned, but may reduce the chance of load/store combining of other bitfields, so it depends on how the bitfields are defined and actually accessed to choose when to use the option. For now the option is off by default.

Differential revision: https://reviews.llvm.org/D36562

llvm-svn: 315915
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CodeGenOptions.def
clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/finegrain-bitfield-access.cpp [new file with mode: 0644]