diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-07-22 13:51:44 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-07-22 13:51:44 +0000 |
commit | e7de47efbec4f33a9d5e111e19eca14c5f79c19a (patch) | |
tree | 8d93edb55a0401eda6df42d0279ec6b37284b188 /clang/lib/CodeGen/CodeGenModule.h | |
parent | f6ce2b5f2e6ab7a01b61f68393c1bf6bd9a49909 (diff) | |
download | bcm5719-llvm-e7de47efbec4f33a9d5e111e19eca14c5f79c19a.tar.gz bcm5719-llvm-e7de47efbec4f33a9d5e111e19eca14c5f79c19a.zip |
[ms-cxxabi] Emit linkonce complete dtors in TUs that need them
Based on Peter Collingbourne's destructor patches.
Prior to this change, clang was considering ?1 to be the complete
destructor and the base destructor, which was wrong. This lead to
crashes when clang tried to emit two LLVM functions with the same name.
In this ABI, TUs with non-inline dtors might not emit a complete
destructor. They are emitted as inline thunks in TUs that need them,
and they always delegate to the base dtors of the complete class and its
virtual bases. This change uses the DeferredDecls machinery to emit
complete dtors as needed.
Currently in clang try body destructors can catch exceptions thrown by
virtual base destructors. In the Microsoft C++ ABI, clang may not have
the destructor definition, in which case clang won't wrap the virtual
virtual base destructor calls in a try-catch. Diagnosing this in user
code is TODO.
Finally, for classes that don't use virtual inheritance, MSVC always
calls the base destructor (?1) directly. This is a useful code size
optimization that avoids emitting lots of extra thunks or aliases.
Implementing it also means our existing tests continue to pass, and is
consistent with MSVC's output.
We can do the same for Itanium by tweaking GetAddrOfCXXDestructor, but
it will require further testing.
Reviewers: rjmccall
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1066
llvm-svn: 186828
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index c2cbe99a668..c99a0ecfc7e 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -752,7 +752,8 @@ public: /// given type. llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, CXXDtorType dtorType, - const CGFunctionInfo *fnInfo = 0); + const CGFunctionInfo *fnInfo = 0, + llvm::FunctionType *fnType = 0); /// getBuiltinLibFunction - Given a builtin id for a function like /// "__builtin_fabsf", return a Function* for "fabsf". @@ -980,6 +981,10 @@ public: DeferredVTables.push_back(RD); } + /// EmitGlobal - Emit code for a singal global function or var decl. Forward + /// declarations are emitted lazily. + void EmitGlobal(GlobalDecl D); + private: llvm::GlobalValue *GetGlobalValue(StringRef Ref); @@ -1011,10 +1016,6 @@ private: llvm::Function *F, bool IsIncompleteFunction); - /// EmitGlobal - Emit code for a singal global function or var decl. Forward - /// declarations are emitted lazily. - void EmitGlobal(GlobalDecl D); - void EmitGlobalDefinition(GlobalDecl D); void EmitGlobalFunctionDefinition(GlobalDecl GD); @@ -1040,10 +1041,6 @@ private: /// a C++ constructor Decl. void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type); - /// EmitCXXDestructors - Emit destructors (base, complete) from a - /// C++ destructor Decl. - void EmitCXXDestructors(const CXXDestructorDecl *D); - /// EmitCXXDestructor - Emit a single destructor with the given type from /// a C++ destructor Decl. void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type); |