More vtable improvements. We now compute and keep track of all vtable related information which avoids computing the same vtable layout over and over.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99403 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGVtable.h b/lib/CodeGen/CGVtable.h
index 4a92443..6670b4e 100644
--- a/lib/CodeGen/CGVtable.h
+++ b/lib/CodeGen/CGVtable.h
@@ -260,11 +260,21 @@
/// Thunks - Contains all thunks that a given method decl will need.
ThunksMapTy Thunks;
-
- /// ClassesWithKnownThunkStatus - Contains all the classes for which we know
- /// whether their virtual member functions have thunks or not.
- llvm::DenseSet<const CXXRecordDecl *> ClassesWithKnownThunkStatus;
+ typedef llvm::DenseMap<const CXXRecordDecl *, uint64_t *> VTableLayoutMapTy;
+
+ /// VTableLayoutMap - Stores the vtable layout for all record decls.
+ /// The layout is stored as an array of 64-bit integers, where the first
+ /// integer is the number of vtable entries in the layout, and the subsequent
+ /// integers are the vtable components.
+ VTableLayoutMapTy VTableLayoutMap;
+
+ uint64_t getNumVTableComponents(const CXXRecordDecl *RD) const {
+ assert(VTableLayoutMap.count(RD) && "No vtable layout for this class!");
+
+ return VTableLayoutMap.lookup(RD)[0];
+ }
+
typedef llvm::DenseMap<ClassPairTy, uint64_t> SubVTTIndiciesTy;
SubVTTIndiciesTy SubVTTIndicies;
@@ -290,6 +300,11 @@
/// EmitThunks - Emit the associated thunks for the given global decl.
void EmitThunks(GlobalDecl GD);
+ /// ComputeVTableRelatedInformation - Compute and store all vtable related
+ /// information (vtable layout, vbase offset offsets, thunks etc) for the
+ /// given record decl.
+ void ComputeVTableRelatedInformation(const CXXRecordDecl *RD);
+
public:
CodeGenVTables(CodeGenModule &CGM)
: CGM(CGM) { }