diff options
| author | Reid Kleckner <reid@kleckner.net> | 2015-03-19 17:03:58 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2015-03-19 17:03:58 +0000 |
| commit | 7270ef5705e36fcad7fdac3529752596abdee74f (patch) | |
| tree | 0ab6db2701fa2735710651871c26863434cdc13e /clang/lib/CodeGen | |
| parent | ca4f699cc2a7b1a3b4b521dc4f7c90673c683f6d (diff) | |
| download | bcm5719-llvm-7270ef5705e36fcad7fdac3529752596abdee74f.tar.gz bcm5719-llvm-7270ef5705e36fcad7fdac3529752596abdee74f.zip | |
Revert "Improvement on sized deallocation from r230160"
This reverts commit r230580.
extern_weak functions don't appear to work on Darwin (PR22951), so we'll
need to come up with a new approach.
llvm-svn: 232731
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 87 |
1 files changed, 5 insertions, 82 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 425a968c13a..6852d3afc7f 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1422,71 +1422,6 @@ CodeGenFunction::pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, OperatorDelete, ElementType); } -static void EmitDelete(CodeGenFunction &CGF, - const CXXDeleteExpr *DE, - llvm::Value *Ptr, - QualType ElementType); - -static void EmitSizedDelete(CodeGenFunction &CGF, - const CXXDeleteExpr *DE, - llvm::Value *Ptr, - QualType ElementType, - FunctionDecl* UnsizedDealloc) { - - if (CGF.getLangOpts().DefineSizedDeallocation) { - // The delete operator in use is fixed. So simply emit the delete expr. - EmitDelete(CGF, DE, Ptr, ElementType); - return; - } - - assert(UnsizedDealloc && "We must be emiting a 'sized' delete expr"); - - // Branch off over the value of operator delete: - // Use the sized form if available, and default on the unsized form otherwise. - llvm::BasicBlock *ThenBlock = CGF.createBasicBlock("if.then"); - llvm::BasicBlock *ContBlock = CGF.createBasicBlock("if.end"); - llvm::BasicBlock *ElseBlock = CGF.createBasicBlock("if.else"); - - // Emit the condition. - const FunctionDecl *OpDelFD = DE->getOperatorDelete(); - llvm::Value *OpDelAddr = CGF.CGM.GetAddrOfFunction(OpDelFD); - //llvm::Function *OpDel = dyn_cast<llvm::Function>(OpDelAddr); - llvm::Value *SDE = CGF.Builder.CreateIsNotNull(OpDelAddr, "sized.del.exists"); - CGF.Builder.CreateCondBr(SDE, ThenBlock, ElseBlock); - - // Emit the 'then' code. - CGF.EmitBlock(ThenBlock); - EmitDelete(CGF, DE, Ptr, ElementType); - CGF.EmitBranch(ContBlock); - - // Compute the 'unsized' delete expr. - CXXDeleteExpr * E = const_cast<CXXDeleteExpr*>(DE); - CXXDeleteExpr *UnsizedDE = - new (CGF.getContext()) CXXDeleteExpr(CGF.getContext().VoidTy, - E->isGlobalDelete(), - E->isArrayForm(), - E->isArrayFormAsWritten(), - E->doesUsualArrayDeleteWantSize(), - UnsizedDealloc, - E->getArgument(), - E->getLocStart()); - // Emit the 'else' code. - { - // There is no need to emit line number for an unconditional branch. - auto NL = ApplyDebugLocation::CreateEmpty(CGF); - CGF.EmitBlock(ElseBlock); - } - EmitDelete(CGF, UnsizedDE, Ptr, ElementType); - { - // There is no need to emit line number for an unconditional branch. - auto NL = ApplyDebugLocation::CreateEmpty(CGF); - CGF.EmitBranch(ContBlock); - } - - // Emit the continuation block for code after the if. - CGF.EmitBlock(ContBlock, true); -} - /// Emit the code for deleting a single object. static void EmitObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, @@ -1646,17 +1581,6 @@ static void EmitArrayDelete(CodeGenFunction &CGF, CGF.PopCleanupBlock(); } -static void EmitDelete(CodeGenFunction &CGF, - const CXXDeleteExpr *DE, - llvm::Value *Ptr, - QualType ElementType) { - if (DE->isArrayForm()) { - EmitArrayDelete(CGF, DE, Ptr, ElementType); - } else { - EmitObjectDelete(CGF, DE, Ptr, ElementType); - } -} - void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { const Expr *Arg = E->getArgument(); llvm::Value *Ptr = EmitScalarExpr(Arg); @@ -1696,12 +1620,11 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { assert(ConvertTypeForMem(DeleteTy) == cast<llvm::PointerType>(Ptr->getType())->getElementType()); - const FunctionDecl *Dealloc = E->getOperatorDelete(); - if (FunctionDecl* UnsizedDealloc = - Dealloc->getCorrespondingUnsizedGlobalDeallocationFunction()) - EmitSizedDelete(*this, E, Ptr, DeleteTy, UnsizedDealloc); - else - EmitDelete(*this, E, Ptr, DeleteTy); + if (E->isArrayForm()) { + EmitArrayDelete(*this, E, Ptr, DeleteTy); + } else { + EmitObjectDelete(*this, E, Ptr, DeleteTy); + } EmitBlock(DeleteEnd); } |

