Remove the old vtable layout code.

llvm-svn: 99869
This commit is contained in:
Anders Carlsson 2010-03-30 03:43:47 +00:00
parent a086edc0e6
commit f141dd1b95
8 changed files with 0 additions and 1360 deletions

View File

@ -297,38 +297,6 @@ void CodeGenModule::getMangledCXXDtorName(MangleBuffer &Name,
getMangleContext().mangleCXXDtor(D, Type, Name.getBuffer());
}
llvm::Constant *
CodeGenModule::GetAddrOfThunk(GlobalDecl GD,
const ThunkAdjustment &ThisAdjustment) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
// Compute mangled name
llvm::SmallString<256> OutName;
if (const CXXDestructorDecl* DD = dyn_cast<CXXDestructorDecl>(MD))
getMangleContext().mangleCXXDtorThunk(DD, GD.getDtorType(), ThisAdjustment,
OutName);
else
getMangleContext().mangleThunk(MD, ThisAdjustment, OutName);
// Get function for mangled name
const llvm::Type *Ty = getTypes().GetFunctionTypeForVtable(MD);
return GetOrCreateLLVMFunction(OutName, Ty, GlobalDecl());
}
llvm::Constant *
CodeGenModule::GetAddrOfCovariantThunk(GlobalDecl GD,
const CovariantThunkAdjustment &Adjustment) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
// Compute mangled name
llvm::SmallString<256> Name;
getMangleContext().mangleCovariantThunk(MD, Adjustment, Name);
// Get function for mangled name
const llvm::Type *Ty = getTypes().GetFunctionTypeForVtable(MD);
return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl());
}
static llvm::Value *BuildVirtualCall(CodeGenFunction &CGF, uint64_t VtableIndex,
llvm::Value *This, const llvm::Type *Ty) {
Ty = Ty->getPointerTo()->getPointerTo()->getPointerTo();

View File

@ -69,42 +69,6 @@ CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *Class,
return llvm::ConstantInt::get(PtrDiffTy, Offset);
}
// FIXME: This probably belongs in CGVtable, but it relies on
// the static function ComputeNonVirtualBaseClassOffset, so we should make that
// a CodeGenModule member function as well.
ThunkAdjustment
CodeGenModule::ComputeThunkAdjustment(const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl) {
CXXBasePaths Paths(/*FindAmbiguities=*/false,
/*RecordPaths=*/true, /*DetectVirtual=*/false);
if (!const_cast<CXXRecordDecl *>(ClassDecl)->
isDerivedFrom(const_cast<CXXRecordDecl *>(BaseClassDecl), Paths)) {
assert(false && "Class must be derived from the passed in base class!");
return ThunkAdjustment();
}
unsigned Start = 0;
uint64_t VirtualOffset = 0;
const CXXBasePath &Path = Paths.front();
const CXXRecordDecl *VBase = 0;
for (unsigned i = 0, e = Path.size(); i != e; ++i) {
const CXXBasePathElement& Element = Path[i];
if (Element.Base->isVirtual()) {
Start = i+1;
QualType VBaseType = Element.Base->getType();
VBase = cast<CXXRecordDecl>(VBaseType->getAs<RecordType>()->getDecl());
}
}
if (VBase)
VirtualOffset =
getVTables().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl);
uint64_t Offset =
ComputeNonVirtualBaseClassOffset(getContext(), Paths.front(), Start);
return ThunkAdjustment(Offset, VirtualOffset);
}
/// Gets the address of a virtual base class within a complete object.
/// This should only be used for (1) non-virtual bases or (2) virtual bases
/// when the type is known to be complete (e.g. in complete destructors).

View File

@ -37,8 +37,6 @@ class VTTBuilder {
/// MostDerivedClassLayout - the AST record layout of the most derived class.
const ASTRecordLayout &MostDerivedClassLayout;
CodeGenVTables::AddrMap_t &AddressPoints;
typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
typedef llvm::DenseMap<BaseSubobject, uint64_t> AddressPointsMapTy;
@ -137,7 +135,6 @@ VTTBuilder::VTTBuilder(CodeGenModule &CGM,
bool GenerateDefinition)
: CGM(CGM), MostDerivedClass(MostDerivedClass),
MostDerivedClassLayout(CGM.getContext().getASTRecordLayout(MostDerivedClass)),
AddressPoints(*CGM.getVTables().OldAddressPoints[MostDerivedClass]),
GenerateDefinition(GenerateDefinition) {
// Lay out this VTT.

File diff suppressed because it is too large Load Diff

View File

@ -113,42 +113,6 @@ struct ThunkInfo {
bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); }
};
/// ThunkAdjustment - Virtual and non-virtual adjustment for thunks.
class ThunkAdjustment {
public:
ThunkAdjustment(int64_t NonVirtual, int64_t Virtual)
: NonVirtual(NonVirtual),
Virtual(Virtual) { }
ThunkAdjustment()
: NonVirtual(0), Virtual(0) { }
// isEmpty - Return whether this thunk adjustment is empty.
bool isEmpty() const {
return NonVirtual == 0 && Virtual == 0;
}
/// NonVirtual - The non-virtual adjustment.
int64_t NonVirtual;
/// Virtual - The virtual adjustment.
int64_t Virtual;
};
/// CovariantThunkAdjustment - Adjustment of the 'this' pointer and the
/// return pointer for covariant thunks.
class CovariantThunkAdjustment {
public:
CovariantThunkAdjustment(const ThunkAdjustment &ThisAdjustment,
const ThunkAdjustment &ReturnAdjustment)
: ThisAdjustment(ThisAdjustment), ReturnAdjustment(ReturnAdjustment) { }
CovariantThunkAdjustment() { }
ThunkAdjustment ThisAdjustment;
ThunkAdjustment ReturnAdjustment;
};
// BaseSubobject - Uniquely identifies a direct or indirect base class.
// Stores both the base class decl and the offset from the most derived class to
// the base class.
@ -215,23 +179,8 @@ namespace clang {
namespace CodeGen {
class CodeGenVTables {
public:
typedef std::vector<std::pair<GlobalDecl, ThunkAdjustment> >
AdjustmentVectorTy;
typedef std::pair<const CXXRecordDecl *, uint64_t> CtorVtable_t;
typedef llvm::DenseMap<CtorVtable_t, int64_t> AddrSubMap_t;
typedef llvm::DenseMap<const CXXRecordDecl *, AddrSubMap_t *> AddrMap_t;
const CodeGenVTables::AddrSubMap_t& getAddressPoints(const CXXRecordDecl *RD);
// FIXME: Remove this.
llvm::DenseMap<const CXXRecordDecl *, AddrMap_t*> OldAddressPoints;
private:
CodeGenModule &CGM;
/// MethodVtableIndices - Contains the index (relative to the vtable address
/// point) where the function pointer for a virtual function is stored.
typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVtableIndicesTy;
@ -318,12 +267,6 @@ private:
uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD);
void ComputeMethodVtableIndices(const CXXRecordDecl *RD);
llvm::GlobalVariable *
GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage,
bool GenerateDefinition, const CXXRecordDecl *LayoutClass,
const CXXRecordDecl *RD, uint64_t Offset, bool IsVirtual,
llvm::DenseMap<BaseSubobject, uint64_t> &AddressPoints);
llvm::GlobalVariable *GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage,
bool GenerateDefinition,

View File

@ -228,11 +228,6 @@ public:
/// GetAddrOfThunk - Get the address of the thunk for the given global decl.
llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk);
llvm::Constant *GetAddrOfThunk(GlobalDecl GD,
const ThunkAdjustment &ThisAdjustment);
llvm::Constant *GetAddrOfCovariantThunk(GlobalDecl GD,
const CovariantThunkAdjustment &ThisAdjustment);
/// GetWeakRefReference - Get a reference to the target of VD.
llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
@ -242,11 +237,6 @@ public:
GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl);
/// ComputeThunkAdjustment - Returns the two parts required to compute the
/// offset for an object.
ThunkAdjustment ComputeThunkAdjustment(const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl);
/// GetStringForStringLiteral - Return the appropriate bytes for a string
/// literal, properly padded to match the literal type. If only the address of
/// a constant is needed consider using GetAddrOfConstantStringLiteral.

View File

@ -102,7 +102,6 @@ public:
llvm::raw_svector_ostream &getStream() { return Out; }
void mangle(const NamedDecl *D, llvm::StringRef Prefix = "_Z");
void mangleCallOffset(const ThunkAdjustment &Adjustment);
void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
void mangleNumber(int64_t Number);
void mangleFunctionEncoding(const FunctionDecl *FD);
@ -440,10 +439,6 @@ void CXXNameMangler::mangleNumber(int64_t Number) {
Out << Number;
}
void CXXNameMangler::mangleCallOffset(const ThunkAdjustment &Adjustment) {
mangleCallOffset(Adjustment.NonVirtual, Adjustment.Virtual);
}
void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
// <call-offset> ::= h <nv-offset> _
// ::= v <v-offset> _
@ -1872,22 +1867,6 @@ void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
Mangler.mangle(D);
}
/// \brief Mangles the a thunk with the offset n for the declaration D and
/// emits that name to the given output stream.
void MangleContext::mangleThunk(const FunctionDecl *FD,
const ThunkAdjustment &ThisAdjustment,
llvm::SmallVectorImpl<char> &Res) {
assert(!isa<CXXDestructorDecl>(FD) &&
"Use mangleCXXDtor for destructor decls!");
// <special-name> ::= T <call-offset> <base encoding>
// # base is the nominal target function of thunk
CXXNameMangler Mangler(*this, Res);
Mangler.getStream() << "_ZT";
Mangler.mangleCallOffset(ThisAdjustment);
Mangler.mangleFunctionEncoding(FD);
}
void MangleContext::mangleThunk(const CXXMethodDecl *MD,
const ThunkInfo &Thunk,
llvm::SmallVectorImpl<char> &Res) {
@ -1934,38 +1913,6 @@ MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type,
Mangler.mangleFunctionEncoding(DD);
}
void MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *D,
CXXDtorType Type,
const ThunkAdjustment &ThisAdjustment,
llvm::SmallVectorImpl<char> &Res) {
// <special-name> ::= T <call-offset> <base encoding>
// # base is the nominal target function of thunk
CXXNameMangler Mangler(*this, Res, D, Type);
Mangler.getStream() << "_ZT";
Mangler.mangleCallOffset(ThisAdjustment);
Mangler.mangleFunctionEncoding(D);
}
/// \brief Mangles the a covariant thunk for the declaration D and emits that
/// name to the given output stream.
void
MangleContext::mangleCovariantThunk(const FunctionDecl *FD,
const CovariantThunkAdjustment& Adjustment,
llvm::SmallVectorImpl<char> &Res) {
assert(!isa<CXXDestructorDecl>(FD) &&
"No such thing as a covariant thunk for a destructor!");
// <special-name> ::= Tc <call-offset> <call-offset> <base encoding>
// # base is the nominal target function of thunk
// # first call-offset is 'this' adjustment
// # second call-offset is result adjustment
CXXNameMangler Mangler(*this, Res);
Mangler.getStream() << "_ZTc";
Mangler.mangleCallOffset(Adjustment.ThisAdjustment);
Mangler.mangleCallOffset(Adjustment.ReturnAdjustment);
Mangler.mangleFunctionEncoding(FD);
}
/// mangleGuardVariable - Returns the mangled name for a guard variable
/// for the passed in VarDecl.
void MangleContext::mangleGuardVariable(const VarDecl *D,

View File

@ -36,8 +36,6 @@ namespace clang {
namespace CodeGen {
struct ThisAdjustment;
struct ThunkInfo;
class CovariantThunkAdjustment;
class ThunkAdjustment;
/// MangleBuffer - a convenient class for storing a name which is
/// either the result of a mangling or is a constant string with
@ -94,21 +92,12 @@ public:
bool shouldMangleDeclName(const NamedDecl *D);
void mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &);
void mangleThunk(const FunctionDecl *FD,
const ThunkAdjustment &ThisAdjustment,
llvm::SmallVectorImpl<char> &);
void mangleThunk(const CXXMethodDecl *MD,
const ThunkInfo &Thunk,
llvm::SmallVectorImpl<char> &);
void mangleCXXDtorThunk(const CXXDestructorDecl *D, CXXDtorType Type,
const ThunkAdjustment &ThisAdjustment,
llvm::SmallVectorImpl<char> &);
void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type,
const ThisAdjustment &ThisAdjustment,
llvm::SmallVectorImpl<char> &);
void mangleCovariantThunk(const FunctionDecl *FD,
const CovariantThunkAdjustment& Adjustment,
llvm::SmallVectorImpl<char> &);
void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl<char> &);
void mangleCXXVtable(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);