[cfe-commits] r78831 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/virt.cpp

Mike Stump mrs at apple.com
Wed Aug 12 11:50:26 PDT 2009


Author: mrs
Date: Wed Aug 12 13:50:26 2009
New Revision: 78831

URL: http://llvm.org/viewvc/llvm-project?rev=78831&view=rev
Log:
Improve the secondary vtables to not include vbase offsets.  WIP.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/test/CodeGenCXX/virt.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78831&r1=78830&r2=78831&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Aug 12 13:50:26 2009
@@ -638,19 +638,21 @@
 
   const ASTRecordLayout &Layout = getContext().getASTRecordLayout(Class);
 
-  // The virtual base offsets come first...
-  for (CXXRecordDecl::reverse_base_class_const_iterator i
-         = Class->bases_rbegin(),
-         e = Class->bases_rend(); i != e; ++i) {
-    if (!i->isVirtual())
-      continue;
-    const CXXRecordDecl *Base = 
-      cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
-    int64_t BaseOffset = Layout.getBaseClassOffset(Base) / 8;
-    llvm::Constant *m;
-    m = llvm::ConstantInt::get(llvm::Type::Int64Ty, BaseOffset);
-    m = llvm::ConstantExpr::getIntToPtr(m, Ptr8Ty);
-    methods.push_back(m);
+  if (isPrimary) {
+    // The virtual base offsets come first...
+    for (CXXRecordDecl::reverse_base_class_const_iterator i
+           = Class->bases_rbegin(),
+           e = Class->bases_rend(); i != e; ++i) {
+      if (!i->isVirtual())
+        continue;
+      const CXXRecordDecl *Base = 
+        cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
+      int64_t BaseOffset = Layout.getBaseClassOffset(Base) / 8;
+      llvm::Constant *m;
+      m = llvm::ConstantInt::get(llvm::Type::Int64Ty, BaseOffset);
+      m = llvm::ConstantExpr::getIntToPtr(m, Ptr8Ty);
+      methods.push_back(m);
+    }
   }
   
   // then comes the the vcall offsets for all our functions...

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Wed Aug 12 13:50:26 2009
@@ -128,6 +128,41 @@
 // CHECK-LP64: .quad __ZN8test3_B16funcB1Ev
 // CHECK-LP64: .quad __ZN7test3_D5funcDEv
 
+struct test4_D : virtual B, virtual C {
+};
+
+// CHECK-LP32:__ZTV7test4_D:
+// CHECK-LP32: .space 4
+// CHECK-LP32: .long 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .long __ZTI7test4_D
+// CHECK-LP32: .long __ZN1C4bee1Ev
+// CHECK-LP32: .long __ZN1C4bee2Ev
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .long 4294967292
+// CHECK-LP32: .long __ZTI7test4_D 
+// CHECK-LP32: .long __ZN1B4bar1Ev
+// CHECK-LP32: .long __ZN1B4bar2Ev
+
+// CHECK-LP64:__ZTV7test4_D:
+// CHECK-LP64: .space 8
+// CHECK-LP64: .quad 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .quad __ZTI7test4_D
+// CHECK-LP64: .quad __ZN1C4bee1Ev
+// CHECK-LP64: .quad __ZN1C4bee2Ev
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .quad 18446744073709551608
+// CHECK-LP64: .quad __ZTI7test4_D
+// CHECK-LP64: .quad __ZN1B4bar1Ev
+// CHECK-LP64: .quad __ZN1B4bar2Ev
+
 
 
 
@@ -210,5 +245,5 @@
 // CHECK-LP64: .quad __ZN2D14bar5Ev
 
 
-test3_D d;
-
+test4_D d4;
+test3_D d3;





More information about the cfe-commits mailing list