summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp37
-rw-r--r--clang/lib/CodeGen/CGCXXABI.cpp14
-rw-r--r--clang/lib/CodeGen/CGCXXABI.h6
-rw-r--r--clang/lib/CodeGen/CGClass.cpp95
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp8
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp52
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp4
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp50
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h6
-rw-r--r--clang/lib/CodeGen/ItaniumCXXABI.cpp5
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp70
11 files changed, 23 insertions, 324 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 8ca53c1b58a9..59aeff6804b6 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -174,6 +174,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
// requires explicit comdat support in the IL.
if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
return true;
+
// Create the alias with no name.
auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
Aliasee, &getModule());
@@ -199,42 +200,6 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
return false;
}
-/// Emit a definition as a global alias for another definition, unconditionally.
-void CodeGenModule::EmitDefinitionAsAlias(GlobalDecl AliasDecl,
- GlobalDecl TargetDecl) {
-
- llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
-
- StringRef MangledName = getMangledName(AliasDecl);
- llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
- if (Entry && !Entry->isDeclaration())
- return;
- auto *Aliasee = cast<llvm::GlobalValue>(GetAddrOfGlobal(TargetDecl));
-
- // Determine the linkage type for the alias.
- llvm::GlobalValue::LinkageTypes Linkage = getFunctionLinkage(AliasDecl);
-
- // Create the alias with no name.
- auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
- Aliasee, &getModule());
- // Destructors are always unnamed_addr.
- Alias->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
- if (Entry) {
- assert(Entry->getValueType() == AliasValueType &&
- Entry->getAddressSpace() == Alias->getAddressSpace() &&
- "declaration exists with different type");
- Alias->takeName(Entry);
- Entry->replaceAllUsesWith(Alias);
- Entry->eraseFromParent();
- } else {
- Alias->setName(MangledName);
- }
-
- // Set any additional necessary attributes for the alias.
- SetCommonAttributes(AliasDecl, Alias);
-}
-
llvm::Function *CodeGenModule::codegenCXXStructor(GlobalDecl GD) {
const CGFunctionInfo &FnInfo = getTypes().arrangeCXXStructorDeclaration(GD);
auto *Fn = cast<llvm::Function>(
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 4051cacbbbc1..30e5dc2b6cbd 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -268,20 +268,6 @@ void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
}
-void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
- QualType eltTy, llvm::Value *&numElements,
- llvm::Value *&allocPtr, CharUnits &cookieSize) {
- assert(eltTy.isDestructedType());
-
- // Derive a char* in the same address space as the pointer.
- ptr = ptr.withElementType(CGF.Int8Ty);
-
- cookieSize = getArrayCookieSizeImpl(eltTy);
- Address allocAddr = CGF.Builder.CreateConstInBoundsByteGEP(ptr, -cookieSize);
- allocPtr = allocAddr.emitRawPointer(CGF);
- numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
-}
-
llvm::Value *CGCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
Address ptr,
CharUnits cookieSize) {
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 47090276c56b..2dd320dbda97 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -583,12 +583,6 @@ public:
QualType ElementType, llvm::Value *&NumElements,
llvm::Value *&AllocPtr, CharUnits &CookieSize);
- /// Reads the array cookie associated with the given pointer,
- /// that should have one.
- void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, QualType ElementType,
- llvm::Value *&NumElements, llvm::Value *&AllocPtr,
- CharUnits &CookieSize);
-
/// Return whether the given global decl needs a VTT parameter.
virtual bool NeedsVTTParameter(GlobalDecl GD);
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index ced175a9a8f0..f782b0cd17da 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1442,95 +1442,6 @@ static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
return true;
}
-static void EmitConditionalArrayDtorCall(const CXXDestructorDecl *DD,
- CodeGenFunction &CGF,
- llvm::Value *ShouldDeleteCondition) {
- Address ThisPtr = CGF.LoadCXXThisAddress();
- llvm::BasicBlock *ScalarBB = CGF.createBasicBlock("dtor.scalar");
- llvm::BasicBlock *callDeleteBB =
- CGF.createBasicBlock("dtor.call_delete_after_array_destroy");
- llvm::BasicBlock *VectorBB = CGF.createBasicBlock("dtor.vector");
- auto *CondTy = cast<llvm::IntegerType>(ShouldDeleteCondition->getType());
- llvm::Value *CheckTheBitForArrayDestroy = CGF.Builder.CreateAnd(
- ShouldDeleteCondition, llvm::ConstantInt::get(CondTy, 2));
- llvm::Value *ShouldDestroyArray =
- CGF.Builder.CreateIsNull(CheckTheBitForArrayDestroy);
- CGF.Builder.CreateCondBr(ShouldDestroyArray, ScalarBB, VectorBB);
-
- CGF.EmitBlock(VectorBB);
-
- llvm::Value *numElements = nullptr;
- llvm::Value *allocatedPtr = nullptr;
- CharUnits cookieSize;
- QualType EltTy = DD->getThisType()->getPointeeType();
- CGF.CGM.getCXXABI().ReadArrayCookie(CGF, ThisPtr, EltTy, numElements,
- allocatedPtr, cookieSize);
-
- // Destroy the elements.
- QualType::DestructionKind dtorKind = EltTy.isDestructedType();
-
- assert(dtorKind);
- assert(numElements && "no element count for a type with a destructor!");
-
- CharUnits elementSize = CGF.getContext().getTypeSizeInChars(EltTy);
- CharUnits elementAlign =
- ThisPtr.getAlignment().alignmentOfArrayElement(elementSize);
-
- llvm::Value *arrayBegin = ThisPtr.emitRawPointer(CGF);
- llvm::Value *arrayEnd = CGF.Builder.CreateInBoundsGEP(
- ThisPtr.getElementType(), arrayBegin, numElements, "delete.end");
-
- // We already checked that the array is not 0-length before entering vector
- // deleting dtor.
- CGF.emitArrayDestroy(arrayBegin, arrayEnd, EltTy, elementAlign,
- CGF.getDestroyer(dtorKind),
- /*checkZeroLength*/ false, CGF.needsEHCleanup(dtorKind));
-
- llvm::BasicBlock *VectorBBCont = CGF.createBasicBlock("dtor.vector.cont");
- CGF.EmitBlock(VectorBBCont);
-
- llvm::Value *CheckTheBitForDeleteCall = CGF.Builder.CreateAnd(
- ShouldDeleteCondition, llvm::ConstantInt::get(CondTy, 1));
-
- llvm::Value *ShouldCallDelete =
- CGF.Builder.CreateIsNull(CheckTheBitForDeleteCall);
- CGF.Builder.CreateCondBr(ShouldCallDelete, CGF.ReturnBlock.getBlock(),
- callDeleteBB);
- CGF.EmitBlock(callDeleteBB);
- const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
- const CXXRecordDecl *ClassDecl = Dtor->getParent();
- assert(Dtor->getArrayOperatorDelete());
- if (!Dtor->getGlobalArrayOperatorDelete()) {
- CGF.EmitDeleteCall(Dtor->getArrayOperatorDelete(), allocatedPtr,
- CGF.getContext().getCanonicalTagType(ClassDecl));
- } else {
- // If global operator[] is set, the class had its own operator delete[].
- // In that case, check the 4th bit. If it is set, we need to call
- // ::delete[].
- llvm::Value *CheckTheBitForGlobDeleteCall = CGF.Builder.CreateAnd(
- ShouldDeleteCondition, llvm::ConstantInt::get(CondTy, 4));
-
- llvm::Value *ShouldCallGlobDelete =
- CGF.Builder.CreateIsNull(CheckTheBitForGlobDeleteCall);
- llvm::BasicBlock *GlobDelete =
- CGF.createBasicBlock("dtor.call_glob_delete_after_array_destroy");
- llvm::BasicBlock *ClassDelete =
- CGF.createBasicBlock("dtor.call_class_delete_after_array_destroy");
- CGF.Builder.CreateCondBr(ShouldCallGlobDelete, ClassDelete, GlobDelete);
- CGF.EmitBlock(ClassDelete);
- CGF.EmitDeleteCall(Dtor->getArrayOperatorDelete(), allocatedPtr,
- CGF.getContext().getCanonicalTagType(ClassDecl));
- CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
-
- CGF.EmitBlock(GlobDelete);
- CGF.EmitDeleteCall(Dtor->getGlobalArrayOperatorDelete(), allocatedPtr,
- CGF.getContext().getCanonicalTagType(ClassDecl));
- }
-
- CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
- CGF.EmitBlock(ScalarBB);
-}
-
/// EmitDestructorBody - Emits the body of the current destructor.
void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl());
@@ -1560,9 +1471,7 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
// outside of the function-try-block, which means it's always
// possible to delegate the destructor body to the complete
// destructor. Do so.
- if (DtorType == Dtor_Deleting || DtorType == Dtor_VectorDeleting) {
- if (CXXStructorImplicitParamValue && DtorType == Dtor_VectorDeleting)
- EmitConditionalArrayDtorCall(Dtor, *this, CXXStructorImplicitParamValue);
+ if (DtorType == Dtor_Deleting) {
RunCleanupsScope DtorEpilogue(*this);
EnterDtorCleanups(Dtor, Dtor_Deleting);
if (HaveInsertPoint()) {
@@ -1593,8 +1502,6 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
llvm_unreachable("not expecting a unified dtor");
case Dtor_Comdat: llvm_unreachable("not expecting a COMDAT");
case Dtor_Deleting: llvm_unreachable("already handled deleting case");
- case Dtor_VectorDeleting:
- llvm_unreachable("already handled vector deleting case");
case Dtor_Complete:
assert((Body || getTarget().getCXXABI().isMicrosoft()) &&
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1489b5116e6c..4eb99cc34227 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2363,13 +2363,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
// Emit MS ABI vftable information. There is only one entry for the
// deleting dtor.
const auto *DD = dyn_cast<CXXDestructorDecl>(Method);
- GlobalDecl GD =
- DD ? GlobalDecl(
- DD, CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts())
- ? Dtor_VectorDeleting
- : Dtor_Deleting)
- : GlobalDecl(Method);
+ GlobalDecl GD = DD ? GlobalDecl(DD, Dtor_Deleting) : GlobalDecl(Method);
MethodVFTableLocation ML =
CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
VIndex = ML.Index;
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index f64cf9f8a6c2..14d8db32bafc 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1206,16 +1206,6 @@ void CodeGenFunction::EmitNewArrayInitializer(
EmitCXXAggrConstructorCall(Ctor, NumElements, CurPtr, CCE,
/*NewPointerIsChecked*/true,
CCE->requiresZeroInitialization());
-
- // For MSVC vector deleting destructors support we record that for the class
- // new[] was called. We try to optimize the code size and only emit vector
- // deleting destructors when they are required. Vector deleting destructors
- // are required for delete[] call but MSVC triggers emission of them
- // whenever new[] is called for an object of the class and we do the same
- // for compatibility.
- if (CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts()))
- CGM.requireVectorDestructorDefinition(Ctor->getParent());
return;
}
@@ -1922,8 +1912,10 @@ static void EmitDestroyingObjectDelete(CodeGenFunction &CGF,
/// Emit the code for deleting a single object.
/// \return \c true if we started emitting UnconditionalDeleteBlock, \c false
/// if not.
-static bool EmitObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE,
- Address Ptr, QualType ElementType,
+static bool EmitObjectDelete(CodeGenFunction &CGF,
+ const CXXDeleteExpr *DE,
+ Address Ptr,
+ QualType ElementType,
llvm::BasicBlock *UnconditionalDeleteBlock) {
// C++11 [expr.delete]p3:
// If the static type of the object to be deleted is different from its
@@ -2117,42 +2109,6 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
DeleteTy = getContext().getBaseElementType(DeleteTy);
Ptr = Ptr.withElementType(ConvertTypeForMem(DeleteTy));
- if (E->isArrayForm() &&
- CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts())) {
- if (auto *RD = DeleteTy->getAsCXXRecordDecl()) {
- auto *Dtor = RD->getDestructor();
- if (Dtor && Dtor->isVirtual()) {
- llvm::Value *NumElements = nullptr;
- llvm::Value *AllocatedPtr = nullptr;
- CharUnits CookieSize;
- llvm::BasicBlock *BodyBB = createBasicBlock("vdtor.call");
- llvm::BasicBlock *DoneBB = createBasicBlock("vdtor.nocall");
- // Check array cookie to see if the array has length 0. Don't call
- // the destructor in that case.
- CGM.getCXXABI().ReadArrayCookie(*this, Ptr, E, DeleteTy, NumElements,
- AllocatedPtr, CookieSize);
-
- auto *CondTy = cast<llvm::IntegerType>(NumElements->getType());
- llvm::Value *IsEmpty = Builder.CreateICmpEQ(
- NumElements, llvm::ConstantInt::get(CondTy, 0));
- Builder.CreateCondBr(IsEmpty, DoneBB, BodyBB);
-
- // Delete cookie for empty array.
- const FunctionDecl *OperatorDelete = E->getOperatorDelete();
- EmitBlock(DoneBB);
- EmitDeleteCall(OperatorDelete, AllocatedPtr, DeleteTy, NumElements,
- CookieSize);
- EmitBranch(DeleteEnd);
-
- EmitBlock(BodyBB);
- if (!EmitObjectDelete(*this, E, Ptr, DeleteTy, DeleteEnd))
- EmitBlock(DeleteEnd);
- return;
- }
- }
- }
-
if (E->isArrayForm()) {
EmitArrayDelete(*this, E, Ptr, DeleteTy);
EmitBlock(DeleteEnd);
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index c95bd9a3067a..3fbac308a917 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -775,9 +775,7 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
case VTableComponent::CK_FunctionPointer:
case VTableComponent::CK_CompleteDtorPointer:
case VTableComponent::CK_DeletingDtorPointer: {
- GlobalDecl GD = component.getGlobalDecl(
- CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts()));
+ GlobalDecl GD = component.getGlobalDecl();
const bool IsThunk =
nextVTableThunkIndex < layout.vtable_thunks().size() &&
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 4bd3e4f8c02c..645b78a599f8 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -8288,53 +8288,3 @@ void CodeGenModule::moveLazyEmissionStates(CodeGenModule *NewBuilder) {
NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
}
-
-bool CodeGenModule::classNeedsVectorDestructor(const CXXRecordDecl *RD) {
- if (!Context.getTargetInfo().emitVectorDeletingDtors(Context.getLangOpts()))
- return false;
- CXXDestructorDecl *Dtor = RD->getDestructor();
- // The compiler can't know if new[]/delete[] will be used outside of the DLL,
- // so just force vector deleting destructor emission if dllexport is present.
- // This matches MSVC behavior.
- if (Dtor && Dtor->isVirtual() && Dtor->isDefined() &&
- Dtor->hasAttr<DLLExportAttr>())
- return true;
-
- return RequireVectorDeletingDtor.count(RD);
-}
-
-void CodeGenModule::requireVectorDestructorDefinition(const CXXRecordDecl *RD) {
- if (!Context.getTargetInfo().emitVectorDeletingDtors(Context.getLangOpts()))
- return;
- RequireVectorDeletingDtor.insert(RD);
-
- // To reduce code size in general case we lazily emit scalar deleting
- // destructor definition and an alias from vector deleting destructor to
- // scalar deleting destructor. It may happen that we first emitted the scalar
- // deleting destructor definition and the alias and then discovered that the
- // definition of the vector deleting destructor is required. Then we need to
- // remove the alias and the scalar deleting destructor and queue vector
- // deleting destructor body for emission. Check if that is the case.
- CXXDestructorDecl *DtorD = RD->getDestructor();
- GlobalDecl ScalarDtorGD(DtorD, Dtor_Deleting);
- StringRef MangledName = getMangledName(ScalarDtorGD);
- llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
- if (Entry && !Entry->isDeclaration()) {
- GlobalDecl VectorDtorGD(DtorD, Dtor_VectorDeleting);
- StringRef VDName = getMangledName(VectorDtorGD);
- llvm::GlobalValue *VDEntry = GetGlobalValue(VDName);
- // It exists and it should be an alias.
- assert(VDEntry && isa<llvm::GlobalAlias>(VDEntry));
- auto *NewFn = llvm::Function::Create(
- cast<llvm::FunctionType>(VDEntry->getValueType()),
- llvm::Function::ExternalLinkage, VDName, &getModule());
- SetFunctionAttributes(VectorDtorGD, NewFn, /*IsIncompleteFunction*/ false,
- /*IsThunk*/ false);
- NewFn->takeName(VDEntry);
- VDEntry->replaceAllUsesWith(NewFn);
- VDEntry->eraseFromParent();
- Entry->replaceAllUsesWith(NewFn);
- Entry->eraseFromParent();
- addDeferredDeclToEmit(VectorDtorGD);
- }
-}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 2acfc83338a0..a253bcda2d06 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -529,9 +529,6 @@ private:
/// that we don't re-emit the initializer.
llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
- /// To remember which types did require a vector deleting dtor.
- llvm::SmallPtrSet<const CXXRecordDecl *, 16> RequireVectorDeletingDtor;
-
typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
GlobalInitData;
@@ -1550,7 +1547,6 @@ public:
void EmitGlobal(GlobalDecl D);
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
- void EmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target);
llvm::GlobalValue *GetGlobalValue(StringRef Ref);
@@ -1828,8 +1824,6 @@ public:
// behavior. So projects like the Linux kernel can rely on it.
return !getLangOpts().CPlusPlus;
}
- void requireVectorDestructorDefinition(const CXXRecordDecl *RD);
- bool classNeedsVectorDestructor(const CXXRecordDecl *RD);
// Helper to get the alignment for a variable.
unsigned getVtableGlobalVarAlignment(const VarDecl *D = nullptr) {
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 82a0acb9cd51..65c47633bc5c 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -93,8 +93,6 @@ public:
llvm_unreachable("emitting dtor comdat as function?");
case Dtor_Unified:
llvm_unreachable("emitting unified dtor as function?");
- case Dtor_VectorDeleting:
- llvm_unreachable("unexpected dtor kind for this ABI");
}
llvm_unreachable("bad dtor kind");
}
@@ -460,8 +458,7 @@ public:
if (!IsInlined)
continue;
- StringRef Name = CGM.getMangledName(
- VtableComponent.getGlobalDecl(/*HasVectorDeletingDtors=*/false));
+ StringRef Name = CGM.getMangledName(VtableComponent.getGlobalDecl());
auto *Entry = CGM.GetGlobalValue(Name);
// This checks if virtual inline function has already been emitted.
// Note that it is possible that this inline function would be emitted
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 11ca94f03cb9..71e24491f19a 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -71,8 +71,8 @@ public:
switch (GD.getDtorType()) {
case Dtor_Complete:
case Dtor_Deleting:
- case Dtor_VectorDeleting:
return true;
+
case Dtor_Base:
return false;
@@ -269,11 +269,7 @@ public:
// There's only Dtor_Deleting in vftable but it shares the this
// adjustment with the base one, so look up the deleting one instead.
- LookupGD = GlobalDecl(
- DD, CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts())
- ? Dtor_VectorDeleting
- : Dtor_Deleting);
+ LookupGD = GlobalDecl(DD, Dtor_Deleting);
}
MethodVFTableLocation ML =
CGM.getMicrosoftVTableContext().getMethodVFTableLocation(LookupGD);
@@ -355,9 +351,8 @@ public:
void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, GlobalDecl GD,
CallArgList &CallArgs) override {
- assert((GD.getDtorType() == Dtor_VectorDeleting ||
- GD.getDtorType() == Dtor_Deleting) &&
- "Only vector deleting destructor thunks are available in this ABI");
+ assert(GD.getDtorType() == Dtor_Deleting &&
+ "Only deleting destructor thunks are available in this ABI");
CallArgs.add(RValue::get(getStructorImplicitParamValue(CGF)),
getContext().IntTy);
}
@@ -1112,8 +1107,7 @@ bool MicrosoftCXXABI::HasThisReturn(GlobalDecl GD) const {
static bool isDeletingDtor(GlobalDecl GD) {
return isa<CXXDestructorDecl>(GD.getDecl()) &&
- (GD.getDtorType() == Dtor_Deleting ||
- GD.getDtorType() == Dtor_VectorDeleting);
+ GD.getDtorType() == Dtor_Deleting;
}
bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) const {
@@ -1366,8 +1360,7 @@ MicrosoftCXXABI::buildStructorSignature(GlobalDecl GD,
AddedStructorArgCounts Added;
// TODO: 'for base' flag
if (isa<CXXDestructorDecl>(GD.getDecl()) &&
- (GD.getDtorType() == Dtor_Deleting ||
- GD.getDtorType() == Dtor_VectorDeleting)) {
+ GD.getDtorType() == Dtor_Deleting) {
// The scalar deleting destructor takes an implicit int parameter.
ArgTys.push_back(getContext().IntTy);
++Added.Suffix;
@@ -1399,7 +1392,7 @@ void MicrosoftCXXABI::setCXXDestructorDLLStorage(llvm::GlobalValue *GV,
CXXDtorType DT) const {
// Deleting destructor variants are never imported or exported. Give them the
// default storage class.
- if (DT == Dtor_Deleting || DT == Dtor_VectorDeleting) {
+ if (DT == Dtor_Deleting) {
GV->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
} else {
const NamedDecl *ND = Dtor;
@@ -1435,12 +1428,6 @@ llvm::GlobalValue::LinkageTypes MicrosoftCXXABI::getCXXDestructorLinkage(
return llvm::GlobalValue::LinkOnceODRLinkage;
case Dtor_Unified:
llvm_unreachable("MS C++ ABI does not support unified dtors");
- case Dtor_VectorDeleting:
- // Use the weak, non-ODR linkage for vector deleting destructors to block
- // inlining. This enables an MS ABI code-size saving optimization that
- // allows us to avoid emitting array deletion code when arrays of a given
- // type are not allocated within the final linkage unit.
- return llvm::GlobalValue::WeakAnyLinkage;
case Dtor_Comdat:
llvm_unreachable("MS C++ ABI does not support comdat dtors");
}
@@ -1472,11 +1459,7 @@ MicrosoftCXXABI::getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {
// There's no Dtor_Base in vftable but it shares the this adjustment with
// the deleting one, so look it up instead.
- GD =
- GlobalDecl(DD, CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts())
- ? Dtor_VectorDeleting
- : Dtor_Deleting);
+ GD = GlobalDecl(DD, Dtor_Deleting);
}
MethodVFTableLocation ML =
@@ -1525,11 +1508,7 @@ Address MicrosoftCXXABI::adjustThisArgumentForVirtualFunctionCall(
// There's only Dtor_Deleting in vftable but it shares the this adjustment
// with the base one, so look up the deleting one instead.
- LookupGD =
- GlobalDecl(DD, CGM.getContext().getTargetInfo().emitVectorDeletingDtors(
- CGM.getContext().getLangOpts())
- ? Dtor_VectorDeleting
- : Dtor_Deleting);
+ LookupGD = GlobalDecl(DD, Dtor_Deleting);
}
MethodVFTableLocation ML =
CGM.getMicrosoftVTableContext().getMethodVFTableLocation(LookupGD);
@@ -2039,30 +2018,24 @@ llvm::Value *MicrosoftCXXABI::EmitVirtualDestructorCall(
auto *CE = dyn_cast<const CXXMemberCallExpr *>(E);
auto *D = dyn_cast<const CXXDeleteExpr *>(E);
assert((CE != nullptr) ^ (D != nullptr));
- assert(CE == nullptr || CE->arg_begin() == CE->arg_end());
- assert(DtorType == Dtor_VectorDeleting || DtorType == Dtor_Complete ||
- DtorType == Dtor_Deleting);
+ assert(CE == nullptr || CE->arguments().empty());
+ assert(DtorType == Dtor_Deleting || DtorType == Dtor_Complete);
// We have only one destructor in the vftable but can get both behaviors
// by passing an implicit int parameter.
- ASTContext &Context = getContext();
- bool VectorDeletingDtorsEnabled =
- Context.getTargetInfo().emitVectorDeletingDtors(Context.getLangOpts());
- GlobalDecl GD(Dtor, VectorDeletingDtorsEnabled ? Dtor_VectorDeleting
- : Dtor_Deleting);
+ GlobalDecl GD(Dtor, Dtor_Deleting);
const CGFunctionInfo *FInfo =
&CGM.getTypes().arrangeCXXStructorDeclaration(GD);
llvm::FunctionType *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
CGCallee Callee = CGCallee::forVirtual(CE, GD, This, Ty);
+ ASTContext &Context = getContext();
bool IsDeleting = DtorType == Dtor_Deleting;
- bool IsArrayDelete = D && D->isArrayForm() && VectorDeletingDtorsEnabled;
bool IsGlobalDelete = D && D->isGlobalDelete() &&
Context.getTargetInfo().callGlobalDeleteInDeletingDtor(
Context.getLangOpts());
llvm::Value *ImplicitParam =
- CGF.Builder.getInt32((IsDeleting ? 1 : 0) | (IsGlobalDelete ? 4 : 0) |
- (IsArrayDelete ? 2 : 0));
+ CGF.Builder.getInt32((IsDeleting ? 1 : 0) | (IsGlobalDelete ? 4 : 0));
QualType ThisTy;
if (CE) {
@@ -2071,9 +2044,6 @@ llvm::Value *MicrosoftCXXABI::EmitVirtualDestructorCall(
ThisTy = D->getDestroyedType();
}
- while (const ArrayType *ATy = Context.getAsArrayType(ThisTy))
- ThisTy = ATy->getElementType();
-
This = adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true);
RValue RV =
CGF.EmitCXXDestructorCall(GD, Callee, This.emitRawPointer(CGF), ThisTy,
@@ -4104,18 +4074,6 @@ void MicrosoftCXXABI::emitCXXStructor(GlobalDecl GD) {
if (GD.getDtorType() == Dtor_Base && !CGM.TryEmitBaseDestructorAsAlias(dtor))
return;
- if (GD.getDtorType() == Dtor_VectorDeleting &&
- !CGM.classNeedsVectorDestructor(dtor->getParent())) {
- // Create GlobalDecl object with the correct type for the scalar
- // deleting destructor.
- GlobalDecl ScalarDtorGD(dtor, Dtor_Deleting);
-
- // Emit an alias from the vector deleting destructor to the scalar deleting
- // destructor.
- CGM.EmitDefinitionAsAlias(GD, ScalarDtorGD);
- return;
- }
-
llvm::Function *Fn = CGM.codegenCXXStructor(GD);
if (Fn->isWeakForLinker())
Fn->setComdat(CGM.getModule().getOrInsertComdat(Fn->getName()));