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

Reid Kleckner rnk at google.com
Fri Jun 28 16:02:19 PDT 2013


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 --------------
A non-text attachment was scrubbed...
Name: D1066.1.patch
Type: text/x-patch
Size: 19032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130628/c7f87f82/attachment.bin>


More information about the cfe-commits mailing list