[PATCH] [ms-cxxabi] Emit linkonce complete dtors in TUs that need them

Reid Kleckner rnk at google.com
Sun Jul 7 10:54:37 PDT 2013


Ping.


On Fri, Jun 28, 2013 at 7:02 PM, Reid Kleckner <rnk at google.com> wrote:

> Hi rjmccall,
>
> 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 in TUs with non-inline dtors where both complete and base dtors
> would be emitted and mangle to the same symbol.
>
> Furthermore, TUs with non-inline dtors don't 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 derived class and its virtual bases.
> This change uses the DeferredDecls machinery to emit them.  There are
> comments in EmitDestructorBody() that suggest this won't work when the
> body of the dtor is a try block, but this is how cl.exe does things.
>
> 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 could probably do the same for Itanium without breaking anything.
> There is an existing -mconstructor-aliases that makes the complete dtor
> a linker alias, but it is off by default.
>
> http://llvm-reviews.chandlerc.com/D1066
>
> Files:
>   include/clang/Basic/TargetCXXABI.h
>   lib/AST/MicrosoftMangle.cpp
>   lib/CodeGen/CGCXX.cpp
>   lib/CodeGen/CGClass.cpp
>   lib/CodeGen/CGExprCXX.cpp
>   lib/CodeGen/CodeGenModule.cpp
>   lib/CodeGen/CodeGenModule.h
>   test/CodeGenCXX/microsoft-abi-structors.cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130707/362d4b8b/attachment.html>


More information about the cfe-commits mailing list