]> granicus.if.org Git - clang/commit
CodeGen: When bitfields fall on natural boundaries, split them up
authorJustin Bogner <mail@justinbogner.com>
Thu, 14 Aug 2014 02:42:10 +0000 (02:42 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 14 Aug 2014 02:42:10 +0000 (02:42 +0000)
commit12d879120bde0fd529b5c87e5102841a0770ae7b
tree1be876ba7ce8db8c3465ca2403540f3e4f557a25
parentf2e6053ef753b2b36f098470af3ca301d65321db
CodeGen: When bitfields fall on natural boundaries, split them up

Currently when laying out bitfields that don't need any padding, we
represent them as a wide enough int to contain all of the bits. This
can be hard on the backend since we'll do things like represent stores
to a few bits as loading an i144, masking it with a large constant,
and storing it back.

This turns up in less pathological cases where we load and mask 64 bit
word on a 32 bit platform when we actually only need to access 32 bits.
This leads to bad code being generated in most of our 32 bit backends.

In practice, there are often natural breaks in bitfields, and it's a
fairly simple and effective heuristic to split these fields into legal
integer sized chunks when it will be equivalent (ie, it won't force us
to add any extra padding).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215614 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGRecordLayoutBuilder.cpp
test/CodeGen/bitfield-machinewords.c [new file with mode: 0644]