[cfe-commits] r128190 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CGClass.cpp CGVTT.cpp CGVTables.cpp CGVTables.h

Ken Dyck kd at kendyck.com
Wed Mar 23 18:21:01 PDT 2011


Author: kjdyck
Date: Wed Mar 23 20:21:01 2011
New Revision: 128190

URL: http://llvm.org/viewvc/llvm-project?rev=128190&view=rev
Log:
Convert the BaseOffset member of BaseSubobject to CharUnits from bits. No
change in functionality intended.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CGVTT.cpp
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/lib/CodeGen/CGVTables.h

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=128190&r1=128189&r2=128190&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Mar 23 20:21:01 2011
@@ -345,7 +345,7 @@
   MD = MD->getCanonicalDecl();
   uint64_t VTableIndex = CGM.getVTables().getMethodVTableIndex(MD);
   uint64_t AddressPoint = 
-    CGM.getVTables().getAddressPoint(BaseSubobject(RD, 0), RD);
+    CGM.getVTables().getAddressPoint(BaseSubobject(RD, CharUnits::Zero()), RD);
   VTableIndex += AddressPoint;
   llvm::Value *VFuncPtr = 
     Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
@@ -380,7 +380,7 @@
     uint64_t VTableIndex = 
       CGM.getVTables().getMethodVTableIndex(GlobalDecl(DD, Type));
     uint64_t AddressPoint =
-      CGM.getVTables().getAddressPoint(BaseSubobject(RD, 0), RD);
+      CGM.getVTables().getAddressPoint(BaseSubobject(RD, CharUnits::Zero()), RD);
     VTableIndex += AddressPoint;
     llvm::Value *VFuncPtr =
       Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=128190&r1=128189&r2=128190&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Mar 23 20:21:01 2011
@@ -305,9 +305,9 @@
   } else {
     const ASTRecordLayout &Layout = 
       CGF.getContext().getASTRecordLayout(RD);
-    uint64_t BaseOffset = ForVirtualBase ? 
-      Layout.getVBaseClassOffsetInBits(Base) : 
-      Layout.getBaseClassOffsetInBits(Base);
+    CharUnits BaseOffset = ForVirtualBase ? 
+      Layout.getVBaseClassOffset(Base) : 
+      Layout.getBaseClassOffset(Base);
 
     SubVTTIndex = 
       CGF.CGM.getVTables().getSubVTTIndex(RD, BaseSubobject(Base, BaseOffset));
@@ -1378,8 +1378,7 @@
     NonVirtualOffset = OffsetFromNearestVBase;
   } else {
     // We can just use the base offset in the complete class.
-    NonVirtualOffset = 
-      CGM.getContext().toCharUnitsFromBits(Base.getBaseOffset());
+    NonVirtualOffset = Base.getBaseOffset();
   }
   
   // Apply the offsets.
@@ -1443,16 +1442,13 @@
     } else {
       const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
 
-      BaseOffset = 
-        getContext().toCharUnitsFromBits(Base.getBaseOffset()) + 
-        Layout.getBaseClassOffset(BaseDecl);
+      BaseOffset = Base.getBaseOffset() + Layout.getBaseClassOffset(BaseDecl);
       BaseOffsetFromNearestVBase = 
         OffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl);
       BaseDeclIsNonVirtualPrimaryBase = Layout.getPrimaryBase() == BaseDecl;
     }
     
-    InitializeVTablePointers(BaseSubobject(BaseDecl, 
-                                           getContext().toBits(BaseOffset)), 
+    InitializeVTablePointers(BaseSubobject(BaseDecl, BaseOffset), 
                              I->isVirtual() ? BaseDecl : NearestVBase,
                              BaseOffsetFromNearestVBase,
                              BaseDeclIsNonVirtualPrimaryBase, 
@@ -1470,7 +1466,8 @@
 
   // Initialize the vtable pointers for this class and all of its bases.
   VisitedVirtualBasesSetTy VBases;
-  InitializeVTablePointers(BaseSubobject(RD, 0), /*NearestVBase=*/0, 
+  InitializeVTablePointers(BaseSubobject(RD, CharUnits::Zero()), 
+                           /*NearestVBase=*/0, 
                            /*OffsetFromNearestVBase=*/CharUnits::Zero(),
                            /*BaseIsNonVirtualPrimaryBase=*/false, 
                            VTable, RD, VBases);

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=128190&r1=128189&r2=128190&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Mar 23 20:21:01 2011
@@ -138,7 +138,8 @@
   GenerateDefinition(GenerateDefinition) {
     
   // Lay out this VTT.
-  LayoutVTT(BaseSubobject(MostDerivedClass, 0), /*BaseIsVirtual=*/false);
+  LayoutVTT(BaseSubobject(MostDerivedClass, CharUnits::Zero()), 
+            /*BaseIsVirtual=*/false);
 }
 
 llvm::Constant *
@@ -148,7 +149,7 @@
     return 0;
   
   if (Base.getBase() == MostDerivedClass) {
-    assert(Base.getBaseOffset() == 0 &&
+    assert(Base.getBaseOffset().isZero() &&
            "Most derived class vtable must have a zero offset!");
     // This is a regular vtable.
     return CGM.getVTables().GetAddrOfVTable(MostDerivedClass);
@@ -217,8 +218,8 @@
       cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
 
     const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
-    uint64_t BaseOffset = Base.getBaseOffset() + 
-      Layout.getBaseClassOffsetInBits(BaseDecl);
+    CharUnits BaseOffset = Base.getBaseOffset() + 
+      Layout.getBaseClassOffset(BaseDecl);
    
     // Layout the VTT for this base.
     LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/false);
@@ -256,19 +257,19 @@
     
     bool BaseDeclIsMorallyVirtual = BaseIsMorallyVirtual;
     bool BaseDeclIsNonVirtualPrimaryBase = false;
-    uint64_t BaseOffset;
+    CharUnits BaseOffset;
     if (I->isVirtual()) {
       // Ignore virtual bases that we've already visited.
       if (!VBases.insert(BaseDecl))
         continue;
       
-      BaseOffset = MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
+      BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
       BaseDeclIsMorallyVirtual = true;
     } else {
       const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
       
-      BaseOffset = 
-        Base.getBaseOffset() + Layout.getBaseClassOffsetInBits(BaseDecl);
+      BaseOffset = Base.getBaseOffset() + 
+        Layout.getBaseClassOffset(BaseDecl);
       
       if (!Layout.isPrimaryBaseVirtual() &&
           Layout.getPrimaryBase() == BaseDecl)
@@ -283,8 +284,8 @@
     if (!BaseDeclIsNonVirtualPrimaryBase &&
         (BaseDecl->getNumVBases() || BaseDeclIsMorallyVirtual)) {
       // Add the vtable pointer.
-      AddVTablePointer(BaseSubobject(BaseDecl, BaseOffset), VTable, VTableClass, 
-                       AddressPoints);
+      AddVTablePointer(BaseSubobject(BaseDecl, BaseOffset), VTable, 
+                       VTableClass, AddressPoints);
     }
 
     // And lay out the secondary virtual pointers for the base class.
@@ -316,8 +317,8 @@
       if (!VBases.insert(BaseDecl))
         continue;
     
-      uint64_t BaseOffset = 
-        MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
+      CharUnits BaseOffset = 
+        MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
       
       LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/true);
     }

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=128190&r1=128189&r2=128190&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Mar 23 20:21:01 2011
@@ -141,7 +141,8 @@
   /// dump - dump the final overriders.
   void dump() {
     VisitedVirtualBasesSetTy VisitedVirtualBases;
-    dump(llvm::errs(), BaseSubobject(MostDerivedClass, 0), VisitedVirtualBases);
+    dump(llvm::errs(), BaseSubobject(MostDerivedClass, CharUnits::Zero()), 
+         VisitedVirtualBases);
   }
   
 };
@@ -160,7 +161,8 @@
   SubobjectOffsetMapTy SubobjectOffsets;
   SubobjectOffsetMapTy SubobjectLayoutClassOffsets;
   SubobjectCountMapTy SubobjectCounts;
-  ComputeBaseOffsets(BaseSubobject(MostDerivedClass, 0), /*IsVirtual=*/false,
+  ComputeBaseOffsets(BaseSubobject(MostDerivedClass, CharUnits::Zero()), 
+                     /*IsVirtual=*/false,
                      MostDerivedClassOffset, SubobjectOffsets, 
                      SubobjectLayoutClassOffsets, SubobjectCounts);
 
@@ -338,7 +340,7 @@
          && "Subobject offset already exists!");
 
   SubobjectOffsets[std::make_pair(RD, SubobjectNumber)] =
-    Base.getBaseOffset();
+    Context.toBits(Base.getBaseOffset());
   SubobjectLayoutClassOffsets[std::make_pair(RD, SubobjectNumber)] =
     OffsetInLayoutClass;
   
@@ -365,13 +367,15 @@
       const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
       uint64_t Offset = Layout.getBaseClassOffsetInBits(BaseDecl);
     
-      BaseOffset = Base.getBaseOffset() + Offset;
+      BaseOffset = Context.toBits(Base.getBaseOffset()) + Offset;
       BaseOffsetInLayoutClass = OffsetInLayoutClass + Offset;
     }
 
-    ComputeBaseOffsets(BaseSubobject(BaseDecl, BaseOffset), I->isVirtual(),
-                       BaseOffsetInLayoutClass, SubobjectOffsets,
-                       SubobjectLayoutClassOffsets, SubobjectCounts);
+    ComputeBaseOffsets(BaseSubobject(BaseDecl, 
+                                     Context.toCharUnitsFromBits(BaseOffset)), 
+                       I->isVirtual(), BaseOffsetInLayoutClass, 
+                       SubobjectOffsets, SubobjectLayoutClassOffsets, 
+                       SubobjectCounts);
   }
 }
 
@@ -389,24 +393,23 @@
     if (!BaseDecl->isPolymorphic())
       continue;
 
-    uint64_t BaseOffset;
+    CharUnits BaseOffset;
     if (I->isVirtual()) {
       if (!VisitedVirtualBases.insert(BaseDecl)) {
         // We've visited this base before.
         continue;
       }
       
-      BaseOffset = MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
+      BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
     } else {
-      BaseOffset = Layout.getBaseClassOffsetInBits(BaseDecl) + 
-        Base.getBaseOffset();
+      BaseOffset = Layout.getBaseClassOffset(BaseDecl) + Base.getBaseOffset();
     }
 
     dump(Out, BaseSubobject(BaseDecl, BaseOffset), VisitedVirtualBases);
   }
 
   Out << "Final overriders for (" << RD->getQualifiedNameAsString() << ", ";
-  Out << Base.getBaseOffset() / 8 << ")\n";
+  Out << Base.getBaseOffset().getQuantity() << ")\n";
 
   // Now dump the overriders for this base subobject.
   for (CXXRecordDecl::method_iterator I = RD->method_begin(), 
@@ -416,7 +419,8 @@
     if (!MD->isVirtual())
       continue;
   
-    OverriderInfo Overrider = getOverrider(MD, Base.getBaseOffset());
+    OverriderInfo Overrider = 
+      getOverrider(MD, Context.toBits(Base.getBaseOffset()));
 
     Out << "  " << MD->getQualifiedNameAsString() << " - (";
     Out << Overrider.Method->getQualifiedNameAsString();
@@ -811,11 +815,13 @@
       assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
              "Primary base should have a zero offset!");
 
-      PrimaryBaseOffset = Base.getBaseOffset();
+      PrimaryBaseOffset = Context.toBits(Base.getBaseOffset());
     }
 
-    AddVCallAndVBaseOffsets(BaseSubobject(PrimaryBase, PrimaryBaseOffset),
-                            PrimaryBaseIsVirtual, RealBaseOffset);
+    AddVCallAndVBaseOffsets(
+      BaseSubobject(PrimaryBase, 
+                    Context.toCharUnitsFromBits(PrimaryBaseOffset)),
+      PrimaryBaseIsVirtual, RealBaseOffset);
   }
 
   AddVBaseOffsets(Base.getBase(), RealBaseOffset);
@@ -878,7 +884,7 @@
     if (Overriders) {
       // Get the final overrider.
       FinalOverriders::OverriderInfo Overrider = 
-        Overriders->getOverrider(MD, Base.getBaseOffset());
+        Overriders->getOverrider(MD, Context.toBits(Base.getBaseOffset()));
       
       /// The vcall offset is the offset from the virtual base to the object 
       /// where the function was overridden.
@@ -902,10 +908,12 @@
       continue;
 
     // Get the base offset of this base.
-    uint64_t BaseOffset = Base.getBaseOffset() + 
+    uint64_t BaseOffset = Context.toBits(Base.getBaseOffset()) + 
       Layout.getBaseClassOffsetInBits(BaseDecl);
     
-    AddVCallOffsets(BaseSubobject(BaseDecl, BaseOffset), VBaseOffset);
+    AddVCallOffsets(
+      BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)), 
+      VBaseOffset);
   }
 }
 
@@ -1376,11 +1384,12 @@
     } else {
       // Otherwise, the non-virtual offset is relative to the derived class 
       // offset.
-      OffsetToBaseSubobject += Derived.getBaseOffset();
+      OffsetToBaseSubobject += Context.toBits(Derived.getBaseOffset());
     }
     
     // Check if this path gives us the right base subobject.
-    if (OffsetToBaseSubobject == Base.getBaseOffset()) {
+    uint64_t BaseOffsetInBits = Context.toBits(Base.getBaseOffset());
+    if (OffsetToBaseSubobject == BaseOffsetInBits) {
       // Since we're going from the base class _to_ the derived class, we'll
       // invert the non-virtual offset here.
       Offset.NonVirtualOffset = -Offset.NonVirtualOffset;
@@ -1400,10 +1409,12 @@
     return ThisAdjustment();
   
   BaseSubobject OverriddenBaseSubobject(MD->getParent(),
-                                        BaseOffsetInLayoutClass);
+                                        Context.toCharUnitsFromBits(
+                                          BaseOffsetInLayoutClass));
   
   BaseSubobject OverriderBaseSubobject(Overrider.Method->getParent(),
-                                       Overrider.Offset);
+                                       Context.toCharUnitsFromBits(
+                                         Overrider.Offset));
   
   // Compute the adjustment offset.
   BaseOffset Offset = ComputeThisAdjustmentBaseOffset(OverriddenBaseSubobject,
@@ -1422,7 +1433,8 @@
       // build them.
       VCallAndVBaseOffsetBuilder Builder(MostDerivedClass, MostDerivedClass,
                                          /*FinalOverriders=*/0,
-                                         BaseSubobject(Offset.VirtualBase, 0),                                           
+                                         BaseSubobject(Offset.VirtualBase,
+                                                       CharUnits::Zero()),
                                          /*BaseIsVirtual=*/true,
                                          /*OffsetInLayoutClass=*/0);
         
@@ -1605,11 +1617,12 @@
       assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
              "Primary base should have a zero offset!");
 
-      PrimaryBaseOffset = Base.getBaseOffset();
+      PrimaryBaseOffset = Context.toBits(Base.getBaseOffset());
       PrimaryBaseOffsetInLayoutClass = BaseOffsetInLayoutClass;
     }
 
-    AddMethods(BaseSubobject(PrimaryBase, PrimaryBaseOffset),
+    AddMethods(BaseSubobject(PrimaryBase, 
+                             Context.toCharUnitsFromBits(PrimaryBaseOffset)),
                PrimaryBaseOffsetInLayoutClass, FirstBaseInPrimaryBaseChain, 
                FirstBaseOffsetInLayoutClass, PrimaryBases);
     
@@ -1627,7 +1640,7 @@
 
     // Get the final overrider.
     FinalOverriders::OverriderInfo Overrider = 
-      Overriders.getOverrider(MD, Base.getBaseOffset());
+      Overriders.getOverrider(MD, Context.toBits(Base.getBaseOffset()));
 
     // Check if this virtual member function overrides a method in a primary
     // base. If this is the case, and the return type doesn't require adjustment
@@ -1642,7 +1655,7 @@
                "Did not find the overridden method!");
         MethodInfo &OverriddenMethodInfo = MethodInfoMap[OverriddenMD];
         
-        MethodInfo MethodInfo(Base.getBaseOffset(), 
+        MethodInfo MethodInfo(Context.toBits(Base.getBaseOffset()), 
                               BaseOffsetInLayoutClass,
                               OverriddenMethodInfo.VTableIndex);
 
@@ -1684,8 +1697,8 @@
     }
 
     // Insert the method info for this method.
-    MethodInfo MethodInfo(Base.getBaseOffset(), BaseOffsetInLayoutClass,
-                          Components.size());
+    MethodInfo MethodInfo(Context.toBits(Base.getBaseOffset()), 
+                          BaseOffsetInLayoutClass, Components.size());
 
     assert(!MethodInfoMap.count(MD) &&
            "Should not have method info for this method yet!");
@@ -1716,7 +1729,8 @@
 }
 
 void VTableBuilder::LayoutVTable() {
-  LayoutPrimaryAndSecondaryVTables(BaseSubobject(MostDerivedClass, 0),
+  LayoutPrimaryAndSecondaryVTables(BaseSubobject(MostDerivedClass,
+                                                 CharUnits::Zero()),
                                    /*BaseIsMorallyVirtual=*/false,
                                    MostDerivedClassIsVirtual,
                                    MostDerivedClassOffset);
@@ -1779,8 +1793,9 @@
   // Add all address points.
   const CXXRecordDecl *RD = Base.getBase();
   while (true) {
-    AddressPoints.insert(std::make_pair(BaseSubobject(RD, OffsetInLayoutClass),
-                                        AddressPoint));
+    AddressPoints.insert(std::make_pair(
+      BaseSubobject(RD, Context.toCharUnitsFromBits(OffsetInLayoutClass)),
+      AddressPoint));
 
     const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
     const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
@@ -1845,23 +1860,26 @@
 
     // Get the base offset of this base.
     uint64_t RelativeBaseOffset = Layout.getBaseClassOffsetInBits(BaseDecl);
-    uint64_t BaseOffset = Base.getBaseOffset() + RelativeBaseOffset;
+    uint64_t BaseOffset = 
+      Context.toBits(Base.getBaseOffset()) + RelativeBaseOffset;
     
     uint64_t BaseOffsetInLayoutClass = OffsetInLayoutClass + RelativeBaseOffset;
     
     // Don't emit a secondary vtable for a primary base. We might however want 
     // to emit secondary vtables for other bases of this base.
     if (BaseDecl == PrimaryBase) {
-      LayoutSecondaryVTables(BaseSubobject(BaseDecl, BaseOffset),
-                             BaseIsMorallyVirtual, BaseOffsetInLayoutClass);
+      LayoutSecondaryVTables(
+        BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)),
+        BaseIsMorallyVirtual, BaseOffsetInLayoutClass);
       continue;
     }
 
     // Layout the primary vtable (and any secondary vtables) for this base.
-    LayoutPrimaryAndSecondaryVTables(BaseSubobject(BaseDecl, BaseOffset),
-                                     BaseIsMorallyVirtual,
-                                     /*BaseIsVirtualInLayoutClass=*/false,
-                                     BaseOffsetInLayoutClass);
+    LayoutPrimaryAndSecondaryVTables(
+      BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)),
+      BaseIsMorallyVirtual,
+      /*BaseIsVirtualInLayoutClass=*/false,
+      BaseOffsetInLayoutClass);
   }
 }
 
@@ -1950,10 +1968,11 @@
       uint64_t BaseOffsetInLayoutClass = 
         LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl);
 
-      LayoutPrimaryAndSecondaryVTables(BaseSubobject(BaseDecl, BaseOffset),
-                                       /*BaseIsMorallyVirtual=*/true,
-                                       /*BaseIsVirtualInLayoutClass=*/true,
-                                       BaseOffsetInLayoutClass);
+      LayoutPrimaryAndSecondaryVTables(
+        BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)),
+        /*BaseIsMorallyVirtual=*/true,
+        /*BaseIsVirtualInLayoutClass=*/true,
+        BaseOffsetInLayoutClass);
     }
     
     // We only need to check the base for virtual base vtables if it actually
@@ -2118,17 +2137,19 @@
         
         // FIXME: Instead of dividing by 8, we should be using CharUnits.
         Out << "       -- (" << Base.getBase()->getQualifiedNameAsString();
-        Out << ", " << Base.getBaseOffset() / 8 << ") vtable address --\n";
+        Out << ", " << Base.getBaseOffset().getQuantity();
+        Out << ") vtable address --\n";
       } else {
-        uint64_t BaseOffset = 
-          AddressPointsByIndex.lower_bound(NextIndex)->second.getBaseOffset();
+        uint64_t BaseOffset = Context.toBits(
+          AddressPointsByIndex.lower_bound(NextIndex)->second.getBaseOffset());
         
         // We store the class names in a set to get a stable order.
         std::set<std::string> ClassNames;
         for (std::multimap<uint64_t, BaseSubobject>::const_iterator I =
              AddressPointsByIndex.lower_bound(NextIndex), E =
              AddressPointsByIndex.upper_bound(NextIndex); I != E; ++I) {
-          assert(I->second.getBaseOffset() == BaseOffset &&
+          assert((uint64_t) Context.toBits(I->second.getBaseOffset()) == 
+                   BaseOffset &&
                  "Invalid base offset!");
           const CXXRecordDecl *RD = I->second.getBase();
           ClassNames.insert(RD->getQualifiedNameAsString());
@@ -2420,7 +2441,7 @@
     return I->second;
   
   VCallAndVBaseOffsetBuilder Builder(RD, RD, /*FinalOverriders=*/0,
-                                     BaseSubobject(RD, 0),                                           
+                                     BaseSubobject(RD, CharUnits::Zero()),
                                      /*BaseIsVirtual=*/false,
                                      /*OffsetInLayoutClass=*/0);
 
@@ -3052,7 +3073,8 @@
                                       const BaseSubobject &Base, 
                                       bool BaseIsVirtual, 
                                       VTableAddressPointsMapTy& AddressPoints) {
-  VTableBuilder Builder(*this, Base.getBase(), Base.getBaseOffset(), 
+  VTableBuilder Builder(*this, Base.getBase(), 
+                        CGM.getContext().toBits(Base.getBaseOffset()), 
                         /*MostDerivedClassIsVirtual=*/BaseIsVirtual, RD);
 
   // Dump the vtable layout if necessary.
@@ -3067,7 +3089,8 @@
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
   CGM.getCXXABI().getMangleContext().
-    mangleCXXCtorVTable(RD, Base.getBaseOffset() / 8, Base.getBase(), Out);
+    mangleCXXCtorVTable(RD, Base.getBaseOffset().getQuantity(), Base.getBase(), 
+                        Out);
   Out.flush();
   llvm::StringRef Name = OutName.str();
 

Modified: cfe/trunk/lib/CodeGen/CGVTables.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.h?rev=128190&r1=128189&r2=128190&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.h (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.h Wed Mar 23 20:21:01 2011
@@ -17,6 +17,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/GlobalVariable.h"
 #include "clang/Basic/ABI.h"
+#include "clang/AST/CharUnits.h"
 #include "GlobalDecl.h"
 
 namespace clang {
@@ -33,17 +34,17 @@
   const CXXRecordDecl *Base;
   
   /// BaseOffset - The offset from the most derived class to the base class.
-  uint64_t BaseOffset;
+  CharUnits BaseOffset;
   
 public:
-  BaseSubobject(const CXXRecordDecl *Base, uint64_t BaseOffset)
+  BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
     : Base(Base), BaseOffset(BaseOffset) { }
   
   /// getBase - Returns the base class declaration.
   const CXXRecordDecl *getBase() const { return Base; }
 
   /// getBaseOffset - Returns the base class offset.
-  uint64_t getBaseOffset() const { return BaseOffset; }
+  CharUnits getBaseOffset() const { return BaseOffset; }
 
   friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
     return LHS.Base == RHS.Base && LHS.BaseOffset == RHS.BaseOffset;
@@ -59,19 +60,19 @@
   static clang::CodeGen::BaseSubobject getEmptyKey() {
     return clang::CodeGen::BaseSubobject(
       DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
-      DenseMapInfo<uint64_t>::getEmptyKey());
+      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getEmptyKey()));
   }
 
   static clang::CodeGen::BaseSubobject getTombstoneKey() {
     return clang::CodeGen::BaseSubobject(
       DenseMapInfo<const clang::CXXRecordDecl *>::getTombstoneKey(),
-      DenseMapInfo<uint64_t>::getTombstoneKey());
+      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getTombstoneKey()));
   }
 
   static unsigned getHashValue(const clang::CodeGen::BaseSubobject &Base) {
     return 
       DenseMapInfo<const clang::CXXRecordDecl *>::getHashValue(Base.getBase()) ^
-      DenseMapInfo<uint64_t>::getHashValue(Base.getBaseOffset());
+      DenseMapInfo<int64_t>::getHashValue(Base.getBaseOffset().getQuantity());
   }
 
   static bool isEqual(const clang::CodeGen::BaseSubobject &LHS, 





More information about the cfe-commits mailing list