<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 5:50 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: d0k<br>
Date: Wed Sep 10 07:50:59 2014<br>
New Revision: 217495<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217495&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217495&view=rev</a><br>
Log:<br>
CodeGen: Use a fixed alignment for vtables.<br></blockquote><div><br></div><div>Any chance this change is to blame for <a href="http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/17224">http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/17224</a> ? Anything I can do to help debug this?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Pointer-sized alignment is sufficient as we only ever read single values<br>
from the table. Otherwise we'd bump the alignment to 16 bytes in the<br>
backend if the vtable is larger than 16 bytes. This is great for<br>
structures that are accessed with vector instructions or copied around, but<br>
that's simply not the case for vtables.<br>
<br>
Shrinks the data segment of a Release x86_64 clang by 0.3%. The wins are<br>
larger for i386 and code bases that use vtables more often than we do.<br>
<br>
This matches the behavior of GCC 5.<br>
<br>
Added:<br>
cfe/trunk/test/CodeGenCXX/vtable-align.cpp<br>
Modified:<br>
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=217495&r1=217494&r2=217495&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=217495&r1=217494&r2=217495&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Sep 10 07:50:59 2014<br>
@@ -1207,6 +1207,12 @@ void ItaniumCXXABI::emitVTableDefinition<br>
// Set the right visibility.<br>
CGM.setGlobalVisibility(VTable, RD);<br>
<br>
+ // Use pointer alignment for the vtable. Otherwise we would align them based<br>
+ // on the size of the initializer which doesn't make sense as only single<br>
+ // values are read.<br>
+ unsigned PAlign = CGM.getTarget().getPointerAlign(0);<br>
+ VTable->setAlignment(getContext().toCharUnitsFromBits(PAlign).getQuantity());<br>
+<br>
// If this is the magic class __cxxabiv1::__fundamental_type_info,<br>
// we will emit the typeinfo for the fundamental types. This is the<br>
// same behaviour as GCC.<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/vtable-align.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-align.cpp?rev=217495&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-align.cpp?rev=217495&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/vtable-align.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/vtable-align.cpp Wed Sep 10 07:50:59 2014<br>
@@ -0,0 +1,14 @@<br>
+// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-32<br>
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-64<br>
+<br>
+struct A {<br>
+ virtual void f();<br>
+ virtual void g();<br>
+ virtual void h();<br>
+};<br>
+<br>
+void A::f() {}<br>
+<br>
+// CHECK-32: @_ZTV1A = unnamed_addr constant [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1fEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1gEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1hEv to i8*)], align 4<br>
+<br>
+// CHECK-64: @_ZTV1A = unnamed_addr constant [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1fEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1gEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1hEv to i8*)], align 8<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>