@@ -1429,70 +1429,6 @@ static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
14291429 return true ;
14301430}
14311431
1432- static void EmitConditionalArrayDtorCall (const CXXDestructorDecl *DD,
1433- CodeGenFunction &CGF,
1434- llvm::Value *ShouldDeleteCondition) {
1435- Address ThisPtr = CGF.LoadCXXThisAddress ();
1436- llvm::BasicBlock *ScalarBB = CGF.createBasicBlock (" dtor.scalar" );
1437- llvm::BasicBlock *callDeleteBB =
1438- CGF.createBasicBlock (" dtor.call_delete_after_array_destroy" );
1439- llvm::BasicBlock *VectorBB = CGF.createBasicBlock (" dtor.vector" );
1440- auto *CondTy = cast<llvm::IntegerType>(ShouldDeleteCondition->getType ());
1441- llvm::Value *CheckTheBitForArrayDestroy = CGF.Builder .CreateAnd (
1442- ShouldDeleteCondition, llvm::ConstantInt::get (CondTy, 2 ));
1443- llvm::Value *ShouldDestroyArray =
1444- CGF.Builder .CreateIsNull (CheckTheBitForArrayDestroy);
1445- CGF.Builder .CreateCondBr (ShouldDestroyArray, ScalarBB, VectorBB);
1446-
1447- CGF.EmitBlock (VectorBB);
1448-
1449- llvm::Value *numElements = nullptr ;
1450- llvm::Value *allocatedPtr = nullptr ;
1451- CharUnits cookieSize;
1452- QualType EltTy = DD->getThisType ()->getPointeeType ();
1453- CGF.CGM .getCXXABI ().ReadArrayCookie (CGF, ThisPtr, EltTy, numElements,
1454- allocatedPtr, cookieSize);
1455-
1456- // Destroy the elements.
1457- QualType::DestructionKind dtorKind = EltTy.isDestructedType ();
1458-
1459- assert (dtorKind);
1460- assert (numElements && " no element count for a type with a destructor!" );
1461-
1462- CharUnits elementSize = CGF.getContext ().getTypeSizeInChars (EltTy);
1463- CharUnits elementAlign =
1464- ThisPtr.getAlignment ().alignmentOfArrayElement (elementSize);
1465-
1466- llvm::Value *arrayBegin = ThisPtr.emitRawPointer (CGF);
1467- llvm::Value *arrayEnd = CGF.Builder .CreateInBoundsGEP (
1468- ThisPtr.getElementType (), arrayBegin, numElements, " delete.end" );
1469-
1470- // We already checked that the array is not 0-length before entering vector
1471- // deleting dtor.
1472- CGF.emitArrayDestroy (arrayBegin, arrayEnd, EltTy, elementAlign,
1473- CGF.getDestroyer (dtorKind),
1474- /* checkZeroLength*/ false , CGF.needsEHCleanup (dtorKind));
1475-
1476- llvm::BasicBlock *VectorBBCont = CGF.createBasicBlock (" dtor.vector.cont" );
1477- CGF.EmitBlock (VectorBBCont);
1478-
1479- llvm::Value *CheckTheBitForDeleteCall = CGF.Builder .CreateAnd (
1480- ShouldDeleteCondition, llvm::ConstantInt::get (CondTy, 1 ));
1481-
1482- llvm::Value *ShouldCallDelete =
1483- CGF.Builder .CreateIsNull (CheckTheBitForDeleteCall);
1484- CGF.Builder .CreateCondBr (ShouldCallDelete, CGF.ReturnBlock .getBlock (),
1485- callDeleteBB);
1486- CGF.EmitBlock (callDeleteBB);
1487- const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl );
1488- const CXXRecordDecl *ClassDecl = Dtor->getParent ();
1489- CGF.EmitDeleteCall (Dtor->getOperatorDelete (), allocatedPtr,
1490- CGF.getContext ().getTagDeclType (ClassDecl));
1491-
1492- CGF.EmitBranchThroughCleanup (CGF.ReturnBlock );
1493- CGF.EmitBlock (ScalarBB);
1494- }
1495-
14961432// / EmitDestructorBody - Emits the body of the current destructor.
14971433void CodeGenFunction::EmitDestructorBody (FunctionArgList &Args) {
14981434 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl ());
@@ -1522,9 +1458,7 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
15221458 // outside of the function-try-block, which means it's always
15231459 // possible to delegate the destructor body to the complete
15241460 // destructor. Do so.
1525- if (DtorType == Dtor_Deleting || DtorType == Dtor_VectorDeleting) {
1526- if (CXXStructorImplicitParamValue && DtorType == Dtor_VectorDeleting)
1527- EmitConditionalArrayDtorCall (Dtor, *this , CXXStructorImplicitParamValue);
1461+ if (DtorType == Dtor_Deleting) {
15281462 RunCleanupsScope DtorEpilogue (*this );
15291463 EnterDtorCleanups (Dtor, Dtor_Deleting);
15301464 if (HaveInsertPoint ()) {
@@ -1553,8 +1487,6 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
15531487 switch (DtorType) {
15541488 case Dtor_Comdat: llvm_unreachable (" not expecting a COMDAT" );
15551489 case Dtor_Deleting: llvm_unreachable (" already handled deleting case" );
1556- case Dtor_VectorDeleting:
1557- llvm_unreachable (" already handled vector deleting case" );
15581490
15591491 case Dtor_Complete:
15601492 assert ((Body || getTarget ().getCXXABI ().isMicrosoft ()) &&
@@ -1637,6 +1569,7 @@ namespace {
16371569 return CGF.EmitScalarExpr (ThisArg);
16381570 return CGF.LoadCXXThis ();
16391571 }
1572+
16401573 // / Call the operator delete associated with the current destructor.
16411574 struct CallDtorDelete final : EHScopeStack::Cleanup {
16421575 CallDtorDelete () {}
@@ -1655,10 +1588,8 @@ namespace {
16551588 bool ReturnAfterDelete) {
16561589 llvm::BasicBlock *callDeleteBB = CGF.createBasicBlock (" dtor.call_delete" );
16571590 llvm::BasicBlock *continueBB = CGF.createBasicBlock (" dtor.continue" );
1658- auto *CondTy = cast<llvm::IntegerType>(ShouldDeleteCondition->getType ());
1659- llvm::Value *CheckTheBit = CGF.Builder .CreateAnd (
1660- ShouldDeleteCondition, llvm::ConstantInt::get (CondTy, 1 ));
1661- llvm::Value *ShouldCallDelete = CGF.Builder .CreateIsNull (CheckTheBit);
1591+ llvm::Value *ShouldCallDelete
1592+ = CGF.Builder .CreateIsNull (ShouldDeleteCondition);
16621593 CGF.Builder .CreateCondBr (ShouldCallDelete, continueBB, callDeleteBB);
16631594
16641595 CGF.EmitBlock (callDeleteBB);
0 commit comments