[cfe-commits] r78309 - /cfe/trunk/test/CodeGenCXX/virt.cpp

Mike Stump mrs at apple.com
Thu Aug 6 07:12:48 PDT 2009


Author: mrs
Date: Thu Aug  6 09:12:47 2009
New Revision: 78309

URL: http://llvm.org/viewvc/llvm-project?rev=78309&view=rev
Log:
Testcase for a recent checkin for vbase layout ordering.  I hate to
optimize and check for non-optimal code, but until the frontend is as
powerful as fold...

Modified:
    cfe/trunk/test/CodeGenCXX/virt.cpp

Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=78309&r1=78308&r2=78309&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Thu Aug  6 09:12:47 2009
@@ -1,6 +1,6 @@
-// RUN: clang-cc -triple x86_64-apple-darwin -frtti=0 -std=c++0x -S %s -o %t-64.s &&
+// RUN: clang-cc -triple x86_64-apple-darwin -frtti=0 -std=c++0x -O3 -S %s -o %t-64.s &&
 // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
-// RUN: clang-cc -triple i386-apple-darwin -frtti=0 -std=c++0x -S %s -o %t-32.s &&
+// RUN: clang-cc -triple i386-apple-darwin -frtti=0 -std=c++0x -O3 -S %s -o %t-32.s &&
 // RUN: FileCheck -check-prefix LP32 -input-file=%t-32.s %s &&
 // RUN: true
 
@@ -24,6 +24,30 @@
 };
 void D::boo() { }
 
+struct D1 {
+  virtual void bar();
+  void *d1;
+};
+void D1::bar() { }
+
+class F : virtual public D1, virtual public D {
+public:
+  virtual void foo();
+  void *f;
+};
+void F::foo() { }
+
+int j;
+void test2() {
+  F f;
+  static int sz = (char *)(&f.f) - (char *)(&f);
+  j = sz;
+  // CHECK-LP32: movl $4, __ZZ5test2vE2sz
+  // CHECK-LP64: movl $8, __ZZ5test2vE2sz(%rip)
+}
+  
+static_assert(sizeof(F) == sizeof(void*)*4, "invalid vbase size");
+
 struct E {
   int e;
 };
@@ -90,23 +114,3 @@
 // CHECK-LP32: .space 4
 // CHECK-LP32: .long __ZN1C4bee1Ev
 // CHECK-LP32: .long __ZN1C4bee2Ev
-
-struct D1 {
-  virtual void bar();
-  void *d1;
-};
-void D1::bar() { }
-
-class F : virtual public D1, virtual public D {
-public:
-  virtual void foo();
-  void *f;
-};
-void F::foo() { }
-
-void test2() {
-  F f;
-  f.f = 0;
-}
-  
-static_assert(sizeof(F) == sizeof(void*)*4, "invalid vbase size");





More information about the cfe-commits mailing list