[cfe-commits] r99462 - in /cfe/trunk/lib/CodeGen: CGVTT.cpp CGVtable.cpp CGVtable.h

Anders Carlsson andersca at mac.com
Wed Mar 24 17:51:13 PDT 2010


Author: andersca
Date: Wed Mar 24 19:51:13 2010
New Revision: 99462

URL: http://llvm.org/viewvc/llvm-project?rev=99462&view=rev
Log:
More address point map shuffling.

Modified:
    cfe/trunk/lib/CodeGen/CGVTT.cpp
    cfe/trunk/lib/CodeGen/CGVtable.cpp
    cfe/trunk/lib/CodeGen/CGVtable.h

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=99462&r1=99461&r2=99462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Mar 24 19:51:13 2010
@@ -247,7 +247,7 @@
              CodeGenModule &cgm, bool GenerateDefinition)
     : Inits(inits), Class(c), CGM(cgm),
       BLayout(cgm.getContext().getASTRecordLayout(c)),
-      AddressPoints(*cgm.getVTables().AddressPoints[c]),
+      AddressPoints(*cgm.getVTables().OldAddressPoints[c]),
       VMContext(cgm.getModule().getContext()),
       GenerateDefinition(GenerateDefinition) {
     

Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=99462&r1=99461&r2=99462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Wed Mar 24 19:51:13 2010
@@ -1093,6 +1093,9 @@
   
   typedef llvm::DenseMap<const CXXRecordDecl *, int64_t> 
     VBaseOffsetOffsetsMapTy;
+  
+  typedef llvm::DenseMap<BaseSubobject, uint64_t> 
+    AddressPointsMapTy;
 
 private:
   /// VTables - Global vtable information.
@@ -1132,8 +1135,6 @@
   /// Components - The components of the vtable being built.
   llvm::SmallVector<VtableComponent, 64> Components;
 
-  typedef llvm::DenseMap<BaseSubobject, uint64_t> AddressPointsMapTy;
-
   /// AddressPoints - Address points for the vtable being built.
   AddressPointsMapTy AddressPoints;
 
@@ -1311,14 +1312,22 @@
     return Components.size();
   }
 
-  const uint64_t *vtable_components_data_begin() {
+  const uint64_t *vtable_components_data_begin() const {
     return reinterpret_cast<const uint64_t *>(Components.begin());
   }
   
-  const uint64_t *vtable_components_data_end() {
+  const uint64_t *vtable_components_data_end() const {
     return reinterpret_cast<const uint64_t *>(Components.end());
   }
   
+  AddressPointsMapTy::const_iterator address_points_begin() const {
+    return AddressPoints.begin();
+  }
+
+  AddressPointsMapTy::const_iterator address_points_end() const {
+    return AddressPoints.end();
+  }
+
   /// dumpLayout - Dump the vtable layout.
   void dumpLayout(llvm::raw_ostream&);
 };
@@ -2481,7 +2490,7 @@
   static llvm::DenseMap<CtorVtable_t, int64_t>&
   AllocAddressPoint(CodeGenModule &cgm, const CXXRecordDecl *l,
                     const CXXRecordDecl *c) {
-    CodeGenVTables::AddrMap_t *&oref = cgm.getVTables().AddressPoints[l];
+    CodeGenVTables::AddrMap_t *&oref = cgm.getVTables().OldAddressPoints[l];
     if (oref == 0)
       oref = new CodeGenVTables::AddrMap_t;
 
@@ -3575,7 +3584,7 @@
 
 const CodeGenVTables::AddrSubMap_t &
 CodeGenVTables::getAddressPoints(const CXXRecordDecl *RD) {
-  if (!AddressPoints[RD]) {
+  if (!OldAddressPoints[RD]) {
     OldVtableBuilder::AddressPointsMapTy AddressPoints;
     OldVtableBuilder b(RD, RD, 0, CGM, false, AddressPoints);
     
@@ -3583,7 +3592,7 @@
     b.GenerateVtableForVBases(RD, 0);
   }
   
-  return *(*AddressPoints[RD])[RD];
+  return *(*OldAddressPoints[RD])[RD];
 }
 
 llvm::GlobalVariable *
@@ -3934,6 +3943,19 @@
   // Add the known thunks.
   Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
   
+  // Add the address points.
+  for (VtableBuilder::AddressPointsMapTy::const_iterator I =
+       Builder.address_points_begin(), E = Builder.address_points_end();
+       I != E; ++I) {
+    
+    uint64_t &AddressPoint = AddressPoints[std::make_pair(RD, I->first)];
+    
+    // Check if we already have the address points for this base.
+    assert(!AddressPoint && "Address point already exists for this base!");
+    
+    AddressPoint = I->second;
+  }
+  
   // If we don't have the vbase information for this class, insert it.
   // getVirtualBaseOffsetOffset will compute it separately without computing
   // the rest of the vtable related information.

Modified: cfe/trunk/lib/CodeGen/CGVtable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.h?rev=99462&r1=99461&r2=99462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.h (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.h Wed Mar 24 19:51:13 2010
@@ -225,7 +225,8 @@
 
   const CodeGenVTables::AddrSubMap_t& getAddressPoints(const CXXRecordDecl *RD);
 
-  llvm::DenseMap<const CXXRecordDecl *, AddrMap_t*> AddressPoints;
+  // FIXME: Remove this.
+  llvm::DenseMap<const CXXRecordDecl *, AddrMap_t*> OldAddressPoints;
 
 private:
   CodeGenModule &CGM;
@@ -269,7 +270,10 @@
 
   typedef llvm::DenseMap<std::pair<const CXXRecordDecl *, 
                                    BaseSubobject>, uint64_t> AddressPointsMapTy;
-
+  
+  /// Address points - Vtable address points.
+  AddressPointsMapTy AddressPoints;
+  
   uint64_t getNumVTableComponents(const CXXRecordDecl *RD) const {
     assert(VTableLayoutMap.count(RD) && "No vtable layout for this class!");
     





More information about the cfe-commits mailing list