[cfe-commits] r99790 - /cfe/trunk/lib/CodeGen/CGClass.cpp

Anders Carlsson andersca at mac.com
Sun Mar 28 18:14:25 PDT 2010


Author: andersca
Date: Sun Mar 28 20:14:25 2010
New Revision: 99790

URL: http://llvm.org/viewvc/llvm-project?rev=99790&view=rev
Log:
When generating base ctors/dtors, we need to lookup virtual bases using the vtable.

Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=99790&r1=99789&r2=99790&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sun Mar 28 20:14:25 2010
@@ -1595,11 +1595,22 @@
   }
 
   // Compute where to store the address point.
-  const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-  llvm::Value *VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
-  VTableField = 
-    Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);  
+  llvm::Value *VTableField;
   
+  if (UseNewVTableCode && 
+      CodeGenVTables::needsVTTParameter(CurGD) && BaseIsMorallyVirtual) {
+    // We need to use the virtual base offset offset because the virtual base
+    // might have a different offset in the most derived class.
+    VTableField = GetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD, 
+                                        /*NullCheckValue=*/false);
+  } else {
+    const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
+
+    VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
+    VTableField = 
+      Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);  
+  }
+
   // Finally, store the address point.
   const llvm::Type *AddressPointPtrTy =
     VTableAddressPoint->getType()->getPointerTo();





More information about the cfe-commits mailing list