[cfe-commits] r90684 - in /cfe/trunk/lib/CodeGen: CGVtable.cpp CGVtable.h CodeGenModule.h
Anders Carlsson
andersca at mac.com
Sat Dec 5 16:01:05 PST 2009
Author: andersca
Date: Sat Dec 5 18:01:05 2009
New Revision: 90684
URL: http://llvm.org/viewvc/llvm-project?rev=90684&view=rev
Log:
Make GenerateVtable a private member function of CGVtableInfo.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/lib/CodeGen/CGVtable.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=90684&r1=90683&r2=90684&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Dec 5 18:01:05 2009
@@ -1111,22 +1111,22 @@
return V;
}
-llvm::Constant *CodeGenModule::GenerateVtable(const CXXRecordDecl *LayoutClass,
- const CXXRecordDecl *RD,
- uint64_t Offset) {
+llvm::GlobalVariable *
+CGVtableInfo::GenerateVtable(const CXXRecordDecl *LayoutClass,
+ const CXXRecordDecl *RD, uint64_t Offset) {
llvm::SmallString<256> OutName;
if (LayoutClass != RD)
- getMangleContext().mangleCXXCtorVtable(LayoutClass, Offset/8, RD, OutName);
+ CGM.getMangleContext().mangleCXXCtorVtable(LayoutClass, Offset / 8,
+ RD, OutName);
else
- getMangleContext().mangleCXXVtable(RD, OutName);
+ CGM.getMangleContext().mangleCXXVtable(RD, OutName);
llvm::StringRef Name = OutName.str();
- llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
int64_t AddressPoint;
- llvm::GlobalVariable *GV = getModule().getGlobalVariable(Name);
- if (GV && AddressPoints[LayoutClass] && !GV->isDeclaration()) {
- AddressPoint=(*(*(AddressPoints[LayoutClass]))[RD])[std::make_pair(RD,
+ llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);
+ if (GV && CGM.AddressPoints[LayoutClass] && !GV->isDeclaration()) {
+ AddressPoint=(*(*(CGM.AddressPoints[LayoutClass]))[RD])[std::make_pair(RD,
Offset)];
// FIXME: We can never have 0 address point. Do this for now so gepping
// retains the same structure. Later, we'll just assert.
@@ -1138,7 +1138,7 @@
CreateDefinition = true;
else {
const ASTRecordLayout &Layout =
- getContext().getASTRecordLayout(LayoutClass);
+ CGM.getContext().getASTRecordLayout(LayoutClass);
if (const CXXMethodDecl *KeyFunction = Layout.getKeyFunction()) {
if (!KeyFunction->getBody()) {
@@ -1149,7 +1149,7 @@
}
}
- VtableBuilder b(RD, LayoutClass, Offset, *this, CreateDefinition);
+ VtableBuilder b(RD, LayoutClass, Offset, CGM, CreateDefinition);
D1(printf("vtable %s\n", RD->getNameAsCString()));
// First comes the vtables for all the non-virtual bases...
@@ -1159,15 +1159,16 @@
b.GenerateVtableForVBases(RD, Offset);
llvm::Constant *Init = 0;
+ const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
llvm::ArrayType *ArrayType =
- llvm::ArrayType::get(Ptr8Ty, b.getVtable().size());
+ llvm::ArrayType::get(Int8PtrTy, b.getVtable().size());
if (CreateDefinition) {
Init = llvm::ConstantArray::get(ArrayType, &b.getVtable()[0],
b.getVtable().size());
}
llvm::GlobalVariable *OGV = GV;
- GV = createGlobalVariable(*this, LayoutClass, ArrayType, Init, Name);
+ GV = createGlobalVariable(CGM, LayoutClass, ArrayType, Init, Name);
if (OGV) {
GV->takeName(OGV);
llvm::Constant *NewPtr =
@@ -1382,23 +1383,24 @@
}
void CGVtableInfo::GenerateClassData(const CXXRecordDecl *RD) {
- Vtables[RD] = CGM.GenerateVtable(RD, RD);
+ Vtables[RD] = GenerateVtable(RD, RD, 0);
CGM.GenerateRTTI(RD);
CGM.GenerateVTT(RD);
}
-llvm::Constant *CGVtableInfo::getVtable(const CXXRecordDecl *RD) {
- llvm::Constant *&Vtable = Vtables[RD];
+llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) {
+ llvm::GlobalVariable *Vtable = Vtables[RD];
+
if (!Vtable)
- Vtable = CGM.GenerateVtable(RD, RD);
+ Vtable = GenerateVtable(RD, RD, 0);
return Vtable;
}
-llvm::Constant *CGVtableInfo::getCtorVtable(const CXXRecordDecl *LayoutClass,
- const CXXRecordDecl *RD,
- uint64_t Offset) {
- return CGM.GenerateVtable(LayoutClass, RD, Offset);
+llvm::GlobalVariable *
+CGVtableInfo::getCtorVtable(const CXXRecordDecl *LayoutClass,
+ const CXXRecordDecl *RD, uint64_t Offset) {
+ return GenerateVtable(LayoutClass, RD, Offset);
}
void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) {
Modified: cfe/trunk/lib/CodeGen/CGVtable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.h?rev=90684&r1=90683&r2=90684&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.h (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.h Sat Dec 5 18:01:05 2009
@@ -18,7 +18,7 @@
#include "GlobalDecl.h"
namespace llvm {
- class Constant;
+ class GlobalVariable;
}
namespace clang {
@@ -79,7 +79,8 @@
typedef llvm::DenseMap<ClassPairTy, int64_t> VirtualBaseClassIndiciesTy;
VirtualBaseClassIndiciesTy VirtualBaseClassIndicies;
- llvm::DenseMap<const CXXRecordDecl *, llvm::Constant *> Vtables;
+ /// Vtables - All the vtables which have been defined.
+ llvm::DenseMap<const CXXRecordDecl *, llvm::GlobalVariable *> Vtables;
/// NumVirtualFunctionPointers - Contains the number of virtual function
/// pointers in the vtable for a given record decl.
@@ -95,7 +96,11 @@
/// upon definition of a KeyFunction. This includes the vtable, the
/// rtti data structure and the VTT.
void GenerateClassData(const CXXRecordDecl *RD);
-
+
+ llvm::GlobalVariable *GenerateVtable(const CXXRecordDecl *LayoutClass,
+ const CXXRecordDecl *RD,
+ uint64_t Offset);
+
public:
CGVtableInfo(CodeGenModule &CGM)
: CGM(CGM) { }
@@ -118,9 +123,10 @@
/// FIXME: This should return a list of address points.
uint64_t getVtableAddressPoint(const CXXRecordDecl *RD);
- llvm::Constant *getVtable(const CXXRecordDecl *RD);
- llvm::Constant *getCtorVtable(const CXXRecordDecl *RD,
- const CXXRecordDecl *Class, uint64_t Offset);
+ llvm::GlobalVariable *getVtable(const CXXRecordDecl *RD);
+ llvm::GlobalVariable *getCtorVtable(const CXXRecordDecl *RD,
+ const CXXRecordDecl *Class,
+ uint64_t Offset);
void MaybeEmitVtable(GlobalDecl GD);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=90684&r1=90683&r2=90684&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Dec 5 18:01:05 2009
@@ -212,15 +212,6 @@
llvm::Constant *GetAddrOfFunction(GlobalDecl GD,
const llvm::Type *Ty = 0);
- /// GenerateVtable - Generate the vtable for the given type. LayoutClass is
- /// the class to use for the virtual base layout information. For
- /// non-construction vtables, this is always the same as RD. Offset is the
- /// offset in bits for the RD object in the LayoutClass, if we're generating a
- /// construction vtable, otherwise 0.
- llvm::Constant *GenerateVtable(const CXXRecordDecl *LayoutClass,
- const CXXRecordDecl *RD,
- uint64_t Offset=0);
-
/// GenerateVTT - Generate the VTT for the given type.
llvm::Constant *GenerateVTT(const CXXRecordDecl *RD);
More information about the cfe-commits
mailing list