diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-10 12:50:59 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-10 12:50:59 +0000 |
| commit | 5d34a2b887a985651cd098153506c45227123b65 (patch) | |
| tree | 3fbaa470ed141e4fb2c9358ba8ca5d256ee48784 /clang/lib | |
| parent | 24b657264502bb9b19eeb368a5adb5e19e58f28b (diff) | |
| download | bcm5719-llvm-5d34a2b887a985651cd098153506c45227123b65.tar.gz bcm5719-llvm-5d34a2b887a985651cd098153506c45227123b65.zip | |
CodeGen: Use a fixed alignment for vtables.
Pointer-sized alignment is sufficient as we only ever read single values
from the table. Otherwise we'd bump the alignment to 16 bytes in the
backend if the vtable is larger than 16 bytes. This is great for
structures that are accessed with vector instructions or copied around, but
that's simply not the case for vtables.
Shrinks the data segment of a Release x86_64 clang by 0.3%. The wins are
larger for i386 and code bases that use vtables more often than we do.
This matches the behavior of GCC 5.
llvm-svn: 217495
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 60b6ecd4ded..b6d08409a88 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1207,6 +1207,12 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT, // Set the right visibility. CGM.setGlobalVisibility(VTable, RD); + // Use pointer alignment for the vtable. Otherwise we would align them based + // on the size of the initializer which doesn't make sense as only single + // values are read. + unsigned PAlign = CGM.getTarget().getPointerAlign(0); + VTable->setAlignment(getContext().toCharUnitsFromBits(PAlign).getQuantity()); + // If this is the magic class __cxxabiv1::__fundamental_type_info, // we will emit the typeinfo for the fundamental types. This is the // same behaviour as GCC. |

