Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed polymorphically

llvm-svn: 245378
This commit is contained in:
David Blaikie 2015-08-18 22:40:54 +00:00
parent d85f7010cc
commit 7e70d6803d
13 changed files with 44 additions and 44 deletions

View File

@ -2239,7 +2239,7 @@ void CodeGenFunction::BuildBlockRelease(llvm::Value *V, BlockFieldFlags flags) {
} }
namespace { namespace {
struct CallBlockRelease : EHScopeStack::Cleanup { struct CallBlockRelease final : EHScopeStack::Cleanup {
llvm::Value *Addr; llvm::Value *Addr;
CallBlockRelease(llvm::Value *Addr) : Addr(Addr) {} CallBlockRelease(llvm::Value *Addr) : Addr(Addr) {}

View File

@ -2851,7 +2851,7 @@ void CodeGenFunction::EmitCallArgs(
namespace { namespace {
struct DestroyUnpassedArg : EHScopeStack::Cleanup { struct DestroyUnpassedArg final : EHScopeStack::Cleanup {
DestroyUnpassedArg(llvm::Value *Addr, QualType Ty) DestroyUnpassedArg(llvm::Value *Addr, QualType Ty)
: Addr(Addr), Ty(Ty) {} : Addr(Addr), Ty(Ty) {}

View File

@ -345,7 +345,7 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD,
namespace { namespace {
/// Call the destructor for a direct base class. /// Call the destructor for a direct base class.
struct CallBaseDtor : EHScopeStack::Cleanup { struct CallBaseDtor final : EHScopeStack::Cleanup {
const CXXRecordDecl *BaseClass; const CXXRecordDecl *BaseClass;
bool BaseIsVirtual; bool BaseIsVirtual;
CallBaseDtor(const CXXRecordDecl *Base, bool BaseIsVirtual) CallBaseDtor(const CXXRecordDecl *Base, bool BaseIsVirtual)
@ -1526,7 +1526,7 @@ void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
namespace { namespace {
/// Call the operator delete associated with the current destructor. /// Call the operator delete associated with the current destructor.
struct CallDtorDelete : EHScopeStack::Cleanup { struct CallDtorDelete final : EHScopeStack::Cleanup {
CallDtorDelete() {} CallDtorDelete() {}
void Emit(CodeGenFunction &CGF, Flags flags) override { void Emit(CodeGenFunction &CGF, Flags flags) override {
@ -1537,7 +1537,7 @@ namespace {
} }
}; };
struct CallDtorDeleteConditional : EHScopeStack::Cleanup { struct CallDtorDeleteConditional final : EHScopeStack::Cleanup {
llvm::Value *ShouldDeleteCondition; llvm::Value *ShouldDeleteCondition;
public: public:
CallDtorDeleteConditional(llvm::Value *ShouldDeleteCondition) CallDtorDeleteConditional(llvm::Value *ShouldDeleteCondition)
@ -1563,7 +1563,7 @@ namespace {
} }
}; };
class DestroyField : public EHScopeStack::Cleanup { class DestroyField final : public EHScopeStack::Cleanup {
const FieldDecl *field; const FieldDecl *field;
CodeGenFunction::Destroyer *destroyer; CodeGenFunction::Destroyer *destroyer;
bool useEHCleanupForArray; bool useEHCleanupForArray;
@ -1933,7 +1933,7 @@ CodeGenFunction::EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor,
} }
namespace { namespace {
struct CallDelegatingCtorDtor : EHScopeStack::Cleanup { struct CallDelegatingCtorDtor final : EHScopeStack::Cleanup {
const CXXDestructorDecl *Dtor; const CXXDestructorDecl *Dtor;
llvm::Value *Addr; llvm::Value *Addr;
CXXDtorType Type; CXXDtorType Type;
@ -1987,7 +1987,7 @@ void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD,
} }
namespace { namespace {
struct CallLocalDtor : EHScopeStack::Cleanup { struct CallLocalDtor final : EHScopeStack::Cleanup {
const CXXDestructorDecl *Dtor; const CXXDestructorDecl *Dtor;
llvm::Value *Addr; llvm::Value *Addr;

View File

@ -400,7 +400,7 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
} }
namespace { namespace {
struct DestroyObject : EHScopeStack::Cleanup { struct DestroyObject final : EHScopeStack::Cleanup {
DestroyObject(llvm::Value *addr, QualType type, DestroyObject(llvm::Value *addr, QualType type,
CodeGenFunction::Destroyer *destroyer, CodeGenFunction::Destroyer *destroyer,
bool useEHCleanupForArray) bool useEHCleanupForArray)
@ -421,7 +421,7 @@ namespace {
} }
}; };
struct DestroyNRVOVariable : EHScopeStack::Cleanup { struct DestroyNRVOVariable final : EHScopeStack::Cleanup {
DestroyNRVOVariable(llvm::Value *addr, DestroyNRVOVariable(llvm::Value *addr,
const CXXDestructorDecl *Dtor, const CXXDestructorDecl *Dtor,
llvm::Value *NRVOFlag) llvm::Value *NRVOFlag)
@ -454,7 +454,7 @@ namespace {
} }
}; };
struct CallStackRestore : EHScopeStack::Cleanup { struct CallStackRestore final : EHScopeStack::Cleanup {
llvm::Value *Stack; llvm::Value *Stack;
CallStackRestore(llvm::Value *Stack) : Stack(Stack) {} CallStackRestore(llvm::Value *Stack) : Stack(Stack) {}
void Emit(CodeGenFunction &CGF, Flags flags) override { void Emit(CodeGenFunction &CGF, Flags flags) override {
@ -464,7 +464,7 @@ namespace {
} }
}; };
struct ExtendGCLifetime : EHScopeStack::Cleanup { struct ExtendGCLifetime final : EHScopeStack::Cleanup {
const VarDecl &Var; const VarDecl &Var;
ExtendGCLifetime(const VarDecl *var) : Var(*var) {} ExtendGCLifetime(const VarDecl *var) : Var(*var) {}
@ -479,7 +479,7 @@ namespace {
} }
}; };
struct CallCleanupFunction : EHScopeStack::Cleanup { struct CallCleanupFunction final : EHScopeStack::Cleanup {
llvm::Constant *CleanupFn; llvm::Constant *CleanupFn;
const CGFunctionInfo &FnInfo; const CGFunctionInfo &FnInfo;
const VarDecl &Var; const VarDecl &Var;
@ -513,7 +513,7 @@ namespace {
}; };
/// A cleanup to call @llvm.lifetime.end. /// A cleanup to call @llvm.lifetime.end.
class CallLifetimeEnd : public EHScopeStack::Cleanup { class CallLifetimeEnd final : public EHScopeStack::Cleanup {
llvm::Value *Addr; llvm::Value *Addr;
llvm::Value *Size; llvm::Value *Size;
public: public:
@ -1548,7 +1548,7 @@ namespace {
/// RegularPartialArrayDestroy - a cleanup which performs a partial /// RegularPartialArrayDestroy - a cleanup which performs a partial
/// array destroy where the end pointer is regularly determined and /// array destroy where the end pointer is regularly determined and
/// does not need to be loaded from a local. /// does not need to be loaded from a local.
class RegularPartialArrayDestroy : public EHScopeStack::Cleanup { class RegularPartialArrayDestroy final : public EHScopeStack::Cleanup {
llvm::Value *ArrayBegin; llvm::Value *ArrayBegin;
llvm::Value *ArrayEnd; llvm::Value *ArrayEnd;
QualType ElementType; QualType ElementType;
@ -1569,7 +1569,7 @@ namespace {
/// IrregularPartialArrayDestroy - a cleanup which performs a /// IrregularPartialArrayDestroy - a cleanup which performs a
/// partial array destroy where the end pointer is irregularly /// partial array destroy where the end pointer is irregularly
/// determined and must be loaded from a local. /// determined and must be loaded from a local.
class IrregularPartialArrayDestroy : public EHScopeStack::Cleanup { class IrregularPartialArrayDestroy final : public EHScopeStack::Cleanup {
llvm::Value *ArrayBegin; llvm::Value *ArrayBegin;
llvm::Value *ArrayEndPointer; llvm::Value *ArrayEndPointer;
QualType ElementType; QualType ElementType;
@ -1641,7 +1641,7 @@ namespace {
/// function. This is used to balance out the incoming +1 of a /// function. This is used to balance out the incoming +1 of a
/// ns_consumed argument when we can't reasonably do that just by /// ns_consumed argument when we can't reasonably do that just by
/// not doing the initial retain for a __block argument. /// not doing the initial retain for a __block argument.
struct ConsumeARCParameter : EHScopeStack::Cleanup { struct ConsumeARCParameter final : EHScopeStack::Cleanup {
ConsumeARCParameter(llvm::Value *param, ConsumeARCParameter(llvm::Value *param,
ARCPreciseLifetime_t precise) ARCPreciseLifetime_t precise)
: Param(param), Precise(precise) {} : Param(param), Precise(precise) {}

View File

@ -327,7 +327,7 @@ static llvm::Constant *getCatchAllValue(CodeGenFunction &CGF) {
namespace { namespace {
/// A cleanup to free the exception object if its initialization /// A cleanup to free the exception object if its initialization
/// throws. /// throws.
struct FreeException : EHScopeStack::Cleanup { struct FreeException final : EHScopeStack::Cleanup {
llvm::Value *exn; llvm::Value *exn;
FreeException(llvm::Value *exn) : exn(exn) {} FreeException(llvm::Value *exn) : exn(exn) {}
void Emit(CodeGenFunction &CGF, Flags flags) override { void Emit(CodeGenFunction &CGF, Flags flags) override {
@ -1087,7 +1087,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
} }
namespace { namespace {
struct CallEndCatchForFinally : EHScopeStack::Cleanup { struct CallEndCatchForFinally final : EHScopeStack::Cleanup {
llvm::Value *ForEHVar; llvm::Value *ForEHVar;
llvm::Value *EndCatchFn; llvm::Value *EndCatchFn;
CallEndCatchForFinally(llvm::Value *ForEHVar, llvm::Value *EndCatchFn) CallEndCatchForFinally(llvm::Value *ForEHVar, llvm::Value *EndCatchFn)
@ -1107,7 +1107,7 @@ namespace {
} }
}; };
struct PerformFinally : EHScopeStack::Cleanup { struct PerformFinally final : EHScopeStack::Cleanup {
const Stmt *Body; const Stmt *Body;
llvm::Value *ForEHVar; llvm::Value *ForEHVar;
llvm::Value *EndCatchFn; llvm::Value *EndCatchFn;
@ -1395,7 +1395,7 @@ void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {
} }
namespace { namespace {
struct PerformSEHFinally : EHScopeStack::Cleanup { struct PerformSEHFinally final : EHScopeStack::Cleanup {
llvm::Function *OutlinedFinally; llvm::Function *OutlinedFinally;
PerformSEHFinally(llvm::Function *OutlinedFinally) PerformSEHFinally(llvm::Function *OutlinedFinally)
: OutlinedFinally(OutlinedFinally) {} : OutlinedFinally(OutlinedFinally) {}

View File

@ -1104,7 +1104,7 @@ RValue CodeGenFunction::EmitBuiltinNewDeleteCall(const FunctionProtoType *Type,
namespace { namespace {
/// A cleanup to call the given 'operator delete' function upon /// A cleanup to call the given 'operator delete' function upon
/// abnormal exit from a new expression. /// abnormal exit from a new expression.
class CallDeleteDuringNew : public EHScopeStack::Cleanup { class CallDeleteDuringNew final : public EHScopeStack::Cleanup {
size_t NumPlacementArgs; size_t NumPlacementArgs;
const FunctionDecl *OperatorDelete; const FunctionDecl *OperatorDelete;
llvm::Value *Ptr; llvm::Value *Ptr;
@ -1157,7 +1157,7 @@ namespace {
/// A cleanup to call the given 'operator delete' function upon /// A cleanup to call the given 'operator delete' function upon
/// abnormal exit from a new expression when the new expression is /// abnormal exit from a new expression when the new expression is
/// conditional. /// conditional.
class CallDeleteDuringConditionalNew : public EHScopeStack::Cleanup { class CallDeleteDuringConditionalNew final : public EHScopeStack::Cleanup {
size_t NumPlacementArgs; size_t NumPlacementArgs;
const FunctionDecl *OperatorDelete; const FunctionDecl *OperatorDelete;
DominatingValue<RValue>::saved_type Ptr; DominatingValue<RValue>::saved_type Ptr;
@ -1422,7 +1422,7 @@ void CodeGenFunction::EmitDeleteCall(const FunctionDecl *DeleteFD,
namespace { namespace {
/// Calls the given 'operator delete' on a single object. /// Calls the given 'operator delete' on a single object.
struct CallObjectDelete : EHScopeStack::Cleanup { struct CallObjectDelete final : EHScopeStack::Cleanup {
llvm::Value *Ptr; llvm::Value *Ptr;
const FunctionDecl *OperatorDelete; const FunctionDecl *OperatorDelete;
QualType ElementType; QualType ElementType;
@ -1507,7 +1507,7 @@ static void EmitObjectDelete(CodeGenFunction &CGF,
namespace { namespace {
/// Calls the given 'operator delete' on an array of objects. /// Calls the given 'operator delete' on an array of objects.
struct CallArrayDelete : EHScopeStack::Cleanup { struct CallArrayDelete final : EHScopeStack::Cleanup {
llvm::Value *Ptr; llvm::Value *Ptr;
const FunctionDecl *OperatorDelete; const FunctionDecl *OperatorDelete;
llvm::Value *NumElements; llvm::Value *NumElements;

View File

@ -451,7 +451,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E,
} }
namespace { namespace {
struct FinishARCDealloc : EHScopeStack::Cleanup { struct FinishARCDealloc final : EHScopeStack::Cleanup {
void Emit(CodeGenFunction &CGF, Flags flags) override { void Emit(CodeGenFunction &CGF, Flags flags) override {
const ObjCMethodDecl *method = cast<ObjCMethodDecl>(CGF.CurCodeDecl); const ObjCMethodDecl *method = cast<ObjCMethodDecl>(CGF.CurCodeDecl);
@ -1304,7 +1304,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
} }
namespace { namespace {
struct DestroyIvar : EHScopeStack::Cleanup { struct DestroyIvar final : EHScopeStack::Cleanup {
private: private:
llvm::Value *addr; llvm::Value *addr;
const ObjCIvarDecl *ivar; const ObjCIvarDecl *ivar;
@ -1743,7 +1743,7 @@ llvm::Value *CodeGenFunction::EmitObjCProduceObject(QualType type,
} }
namespace { namespace {
struct CallObjCRelease : EHScopeStack::Cleanup { struct CallObjCRelease final : EHScopeStack::Cleanup {
CallObjCRelease(llvm::Value *object) : object(object) {} CallObjCRelease(llvm::Value *object) : object(object) {}
llvm::Value *object; llvm::Value *object;
@ -2350,7 +2350,7 @@ void CodeGenFunction::destroyARCWeak(CodeGenFunction &CGF,
} }
namespace { namespace {
struct CallObjCAutoreleasePoolObject : EHScopeStack::Cleanup { struct CallObjCAutoreleasePoolObject final : EHScopeStack::Cleanup {
llvm::Value *Token; llvm::Value *Token;
CallObjCAutoreleasePoolObject(llvm::Value *token) : Token(token) {} CallObjCAutoreleasePoolObject(llvm::Value *token) : Token(token) {}
@ -2359,7 +2359,7 @@ namespace {
CGF.EmitObjCAutoreleasePoolPop(Token); CGF.EmitObjCAutoreleasePoolPop(Token);
} }
}; };
struct CallObjCMRRAutoreleasePoolObject : EHScopeStack::Cleanup { struct CallObjCMRRAutoreleasePoolObject final : EHScopeStack::Cleanup {
llvm::Value *Token; llvm::Value *Token;
CallObjCMRRAutoreleasePoolObject(llvm::Value *token) : Token(token) {} CallObjCMRRAutoreleasePoolObject(llvm::Value *token) : Token(token) {}

View File

@ -3421,7 +3421,7 @@ void CGObjCMac::EmitSynchronizedStmt(CodeGenFunction &CGF,
} }
namespace { namespace {
struct PerformFragileFinally : EHScopeStack::Cleanup { struct PerformFragileFinally final : EHScopeStack::Cleanup {
const Stmt &S; const Stmt &S;
llvm::Value *SyncArgSlot; llvm::Value *SyncArgSlot;
llvm::Value *CallTryExitVar; llvm::Value *CallTryExitVar;

View File

@ -152,7 +152,7 @@ namespace {
llvm::Constant *TypeInfo; llvm::Constant *TypeInfo;
}; };
struct CallObjCEndCatch : EHScopeStack::Cleanup { struct CallObjCEndCatch final : EHScopeStack::Cleanup {
CallObjCEndCatch(bool MightThrow, llvm::Value *Fn) : CallObjCEndCatch(bool MightThrow, llvm::Value *Fn) :
MightThrow(MightThrow), Fn(Fn) {} MightThrow(MightThrow), Fn(Fn) {}
bool MightThrow; bool MightThrow;
@ -297,7 +297,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
} }
namespace { namespace {
struct CallSyncExit : EHScopeStack::Cleanup { struct CallSyncExit final : EHScopeStack::Cleanup {
llvm::Value *SyncExitFn; llvm::Value *SyncExitFn;
llvm::Value *SyncArg; llvm::Value *SyncArg;
CallSyncExit(llvm::Value *SyncExitFn, llvm::Value *SyncArg) CallSyncExit(llvm::Value *SyncExitFn, llvm::Value *SyncArg)

View File

@ -1246,7 +1246,7 @@ llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
} }
namespace { namespace {
template <size_t N> class CallEndCleanup : public EHScopeStack::Cleanup { template <size_t N> class CallEndCleanup final : public EHScopeStack::Cleanup {
llvm::Value *Callee; llvm::Value *Callee;
llvm::Value *Args[N]; llvm::Value *Args[N];

View File

@ -145,6 +145,9 @@ public:
// Anchor the construction vtable. // Anchor the construction vtable.
virtual void anchor(); virtual void anchor();
protected:
~Cleanup() = default;
public: public:
Cleanup(const Cleanup &) = default; Cleanup(const Cleanup &) = default;
Cleanup(Cleanup &&) {} Cleanup(Cleanup &&) {}
@ -176,10 +179,6 @@ public:
void setIsEHCleanupKind() { flags |= F_IsEHCleanupKind; } void setIsEHCleanupKind() { flags |= F_IsEHCleanupKind; }
}; };
// Provide a virtual destructor to suppress a very common warning
// that unfortunately cannot be suppressed without this. Cleanups
// should not rely on this destructor ever being called.
virtual ~Cleanup() {}
/// Emit the cleanup. For normal cleanups, this is run in the /// Emit the cleanup. For normal cleanups, this is run in the
/// same EH context as when the cleanup was pushed, i.e. the /// same EH context as when the cleanup was pushed, i.e. the
@ -192,7 +191,8 @@ public:
/// ConditionalCleanup stores the saved form of its parameters, /// ConditionalCleanup stores the saved form of its parameters,
/// then restores them and performs the cleanup. /// then restores them and performs the cleanup.
template <class T, class... As> class ConditionalCleanup : public Cleanup { template <class T, class... As>
class ConditionalCleanup final : public Cleanup {
typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple; typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
SavedTuple Saved; SavedTuple Saved;

View File

@ -1766,7 +1766,7 @@ static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
} }
namespace { namespace {
struct CallGuardAbort : EHScopeStack::Cleanup { struct CallGuardAbort final : EHScopeStack::Cleanup {
llvm::GlobalVariable *Guard; llvm::GlobalVariable *Guard;
CallGuardAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {} CallGuardAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {}
@ -3367,7 +3367,7 @@ namespace {
/// of the caught type, so we have to assume the actual thrown /// of the caught type, so we have to assume the actual thrown
/// exception type might have a throwing destructor, even if the /// exception type might have a throwing destructor, even if the
/// caught type's destructor is trivial or nothrow. /// caught type's destructor is trivial or nothrow.
struct CallEndCatch : EHScopeStack::Cleanup { struct CallEndCatch final : EHScopeStack::Cleanup {
CallEndCatch(bool MightThrow) : MightThrow(MightThrow) {} CallEndCatch(bool MightThrow) : MightThrow(MightThrow) {}
bool MightThrow; bool MightThrow;

View File

@ -851,7 +851,7 @@ void MicrosoftCXXABI::emitRethrow(CodeGenFunction &CGF, bool isNoReturn) {
} }
namespace { namespace {
struct CallEndCatchMSVC : EHScopeStack::Cleanup { struct CallEndCatchMSVC final : EHScopeStack::Cleanup {
llvm::CatchPadInst *CPI; llvm::CatchPadInst *CPI;
CallEndCatchMSVC(llvm::CatchPadInst *CPI) : CPI(CPI) {} CallEndCatchMSVC(llvm::CatchPadInst *CPI) : CPI(CPI) {}
@ -2252,7 +2252,7 @@ static llvm::Constant *getInitThreadAbortFn(CodeGenModule &CGM) {
} }
namespace { namespace {
struct ResetGuardBit : EHScopeStack::Cleanup { struct ResetGuardBit final : EHScopeStack::Cleanup {
llvm::GlobalVariable *Guard; llvm::GlobalVariable *Guard;
unsigned GuardNum; unsigned GuardNum;
ResetGuardBit(llvm::GlobalVariable *Guard, unsigned GuardNum) ResetGuardBit(llvm::GlobalVariable *Guard, unsigned GuardNum)
@ -2269,7 +2269,7 @@ struct ResetGuardBit : EHScopeStack::Cleanup {
} }
}; };
struct CallInitThreadAbort : EHScopeStack::Cleanup { struct CallInitThreadAbort final : EHScopeStack::Cleanup {
llvm::GlobalVariable *Guard; llvm::GlobalVariable *Guard;
CallInitThreadAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {} CallInitThreadAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {}