]> granicus.if.org Git - clang/commit
Complete Rewrite of CGRecordLayoutBuilder
authorWarren Hunt <whunt@google.com>
Fri, 21 Feb 2014 23:49:50 +0000 (23:49 +0000)
committerWarren Hunt <whunt@google.com>
Fri, 21 Feb 2014 23:49:50 +0000 (23:49 +0000)
commit21db05d136d6af2e90dcb148a307a71908d31049
tree10ec44dabec4c2e21c071f52a80d4523305ac7a6
parent9298d56cfbc5abd66ec296f7ea1273dd25339ed6
Complete Rewrite of CGRecordLayoutBuilder

CGRecordLayoutBuilder was aging, complex, multi-pass, and shows signs of
existing before ASTRecordLayoutBuilder.  It redundantly performed many
layout operations that are now performed by ASTRecordLayoutBuilder and
asserted that the results were the same.  With the addition of support
for the MS-ABI, such as placement of vbptrs, vtordisps, different
bitfield layout and a variety of other features, CGRecordLayoutBuilder
was growing unwieldy in its redundancy.

This patch re-architects CGRecordLayoutBuilder to not perform any
redundant layout but rather, as directly as possible, lower an
ASTRecordLayout to an llvm::type.  The new architecture is significantly
smaller and simpler than the CGRecordLayoutBuilder and contains fewer
ABI-specific code paths.  It's also one pass.

The architecture of the new system is described in the comments. For the
most part, the new system simply takes all of the fields and bases from
an ASTRecordLayout, sorts them, inserts padding and dumps a record.
Bitfields, unions and primary virtual bases make this process a bit more
complicated.  See the inline comments.

In addition, this patch updates a few lit tests due to the fact that the
new system computes more accurate llvm types than CGRecordLayoutBuilder.
Each change is commented individually in the review.

Differential Revision: http://llvm-reviews.chandlerc.com/D2795

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201907 91177308-0d34-0410-b5e6-96231b3b80d8
15 files changed:
lib/CodeGen/CGRecordLayoutBuilder.cpp
test/CodeGen/PR4611-bitfield-layout.c
test/CodeGen/bitfield-2.c
test/CodeGen/packed-nest-unpacked.c
test/CodeGen/packed-union.c
test/CodeGen/pragma-pack-1.c
test/CodeGen/pragma-pack-2.c
test/CodeGen/struct-x86-darwin.c
test/CodeGen/volatile.c
test/CodeGenCXX/bitfield-layout.cpp
test/CodeGenCXX/class-layout.cpp
test/CodeGenCXX/copy-constructor-synthesis.cpp
test/CodeGenCXX/pragma-pack-3.cpp
test/CodeGenCXX/vtable-layout-abi-examples.cpp
test/Sema/ms_class_layout.cpp