зеркало из https://github.com/microsoft/clang-1.git
Always emit associated thunks when emitting the function itself. Remove getVtableAddressPoint, it's not used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
13189d0a18
Коммит
7270ee4cd4
|
@ -489,11 +489,17 @@ CodeGenModule::GetAddrOfCovariantThunk(GlobalDecl GD,
|
|||
}
|
||||
|
||||
void CodeGenModule::BuildThunksForVirtual(GlobalDecl GD) {
|
||||
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
|
||||
|
||||
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD))
|
||||
GD = GlobalDecl(DD, GD.getDtorType());
|
||||
else
|
||||
GD = MD->getCanonicalDecl();
|
||||
|
||||
CodeGenVTables::AdjustmentVectorTy *AdjPtr = getVTables().getAdjustments(GD);
|
||||
if (!AdjPtr)
|
||||
return;
|
||||
CodeGenVTables::AdjustmentVectorTy &Adj = *AdjPtr;
|
||||
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
|
||||
for (unsigned i = 0; i < Adj.size(); i++) {
|
||||
GlobalDecl OGD = Adj[i].first;
|
||||
const CXXMethodDecl *OMD = cast<CXXMethodDecl>(OGD.getDecl());
|
||||
|
|
|
@ -3662,13 +3662,6 @@ int64_t CodeGenVTables::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD,
|
|||
return I->second;
|
||||
}
|
||||
|
||||
uint64_t CodeGenVTables::getVtableAddressPoint(const CXXRecordDecl *RD) {
|
||||
uint64_t AddressPoint =
|
||||
(*(*(CGM.getVTables().AddressPoints[RD]))[RD])[std::make_pair(RD, 0)];
|
||||
|
||||
return AddressPoint;
|
||||
}
|
||||
|
||||
llvm::GlobalVariable *
|
||||
CodeGenVTables::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage,
|
||||
bool GenerateDefinition,
|
||||
|
@ -3754,21 +3747,6 @@ CodeGenVTables::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage,
|
|||
/*IsVirtual=*/false,
|
||||
AddressPoints);
|
||||
GenerateVTT(Linkage, /*GenerateDefinition=*/true, RD);
|
||||
|
||||
for (CXXRecordDecl::method_iterator i = RD->method_begin(),
|
||||
e = RD->method_end(); i != e; ++i) {
|
||||
if (!(*i)->isVirtual())
|
||||
continue;
|
||||
if(!(*i)->hasInlineBody() && !(*i)->isImplicit())
|
||||
continue;
|
||||
|
||||
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(*i)) {
|
||||
CGM.BuildThunksForVirtual(GlobalDecl(DD, Dtor_Complete));
|
||||
CGM.BuildThunksForVirtual(GlobalDecl(DD, Dtor_Deleting));
|
||||
} else {
|
||||
CGM.BuildThunksForVirtual(GlobalDecl(*i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llvm::GlobalVariable *CodeGenVTables::getVtable(const CXXRecordDecl *RD) {
|
||||
|
@ -3792,6 +3770,10 @@ void CodeGenVTables::EmitVTableRelatedData(GlobalDecl GD) {
|
|||
if (!RD->isDynamicClass())
|
||||
return;
|
||||
|
||||
// Check if we need to emit thunks for this function.
|
||||
if (MD->isVirtual())
|
||||
CGM.BuildThunksForVirtual(GD);
|
||||
|
||||
// Get the key function.
|
||||
const CXXMethodDecl *KeyFunction = CGM.getContext().getKeyFunction(RD);
|
||||
|
||||
|
|
|
@ -214,11 +214,6 @@ public:
|
|||
|
||||
AdjustmentVectorTy *getAdjustments(GlobalDecl GD);
|
||||
|
||||
/// getVtableAddressPoint - returns the address point of the vtable for the
|
||||
/// given record decl.
|
||||
/// FIXME: This should return a list of address points.
|
||||
uint64_t getVtableAddressPoint(const CXXRecordDecl *RD);
|
||||
|
||||
llvm::GlobalVariable *getVtable(const CXXRecordDecl *RD);
|
||||
|
||||
/// CtorVtableInfo - Information about a constructor vtable.
|
||||
|
|
|
@ -714,20 +714,9 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
|
|||
Context.getSourceManager(),
|
||||
"Generating code for declaration");
|
||||
|
||||
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
|
||||
if (isa<CXXMethodDecl>(D))
|
||||
getVTables().EmitVTableRelatedData(GD);
|
||||
if (MD->isVirtual() && MD->isOutOfLine() &&
|
||||
(!isa<CXXDestructorDecl>(D) || GD.getDtorType() != Dtor_Base)) {
|
||||
if (isa<CXXDestructorDecl>(D)) {
|
||||
GlobalDecl CanonGD(cast<CXXDestructorDecl>(D->getCanonicalDecl()),
|
||||
GD.getDtorType());
|
||||
BuildThunksForVirtual(CanonGD);
|
||||
} else {
|
||||
BuildThunksForVirtual(MD->getCanonicalDecl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
|
||||
EmitCXXConstructor(CD, GD.getCtorType());
|
||||
else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
|
||||
|
@ -758,7 +747,7 @@ CodeGenModule::GetOrCreateLLVMFunction(llvm::StringRef MangledName,
|
|||
if (WeakRefReferences.count(Entry)) {
|
||||
const FunctionDecl *FD = cast_or_null<FunctionDecl>(D.getDecl());
|
||||
if (FD && !FD->hasAttr<WeakAttr>())
|
||||
Entry->setLinkage(llvm::Function::ExternalLinkage);
|
||||
Entry->setLinkage(llvm::Function::ExternalLinkage);
|
||||
|
||||
WeakRefReferences.erase(Entry);
|
||||
}
|
||||
|
@ -873,7 +862,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
|
|||
if (Entry) {
|
||||
if (WeakRefReferences.count(Entry)) {
|
||||
if (D && !D->hasAttr<WeakAttr>())
|
||||
Entry->setLinkage(llvm::Function::ExternalLinkage);
|
||||
Entry->setLinkage(llvm::Function::ExternalLinkage);
|
||||
|
||||
WeakRefReferences.erase(Entry);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче