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

Reid Kleckner rnk at google.com
Fri Jul 12 06:58:14 PDT 2013

  Adding a predicate to one of the CXXABI classes.

Comment at: lib/AST/MicrosoftMangle.cpp:588
@@ +587,3 @@
+  case Dtor_Complete: Out << "?_D"; return;
+  // <operator-name> ::= ?_G # scalar deleting destructor
+  case Dtor_Deleting: Out << "?_G"; return;
Timur Iskhodzhanov wrote:
> Can we have aliasing Dtor types or at least a comment about this in include/clang/Basic/ABI.h ?
> The current mapping is very confusing.
There's already a comment on the place that does the magical aliasing.  To me this code is much *less* confusing now that we aren't conflating Base and Complete dtors.

Comment at: lib/CodeGen/CGCXX.cpp:285
@@ +284,3 @@
+  // size by calling the base dtor directly.
+  // XXX: We could do this for Itanium, but we should consult with John first.
+  if (getTarget().getCXXABI().isMicrosoft() && dtorType == Dtor_Complete &&
Timur Iskhodzhanov wrote:
> +1 for doing it in all ABIs.
I should also mention that we could turn on -fconstructor-aliases by default on Windows to use a proper linker alias, but I am afraid there are bugs in COFF MC today and I wasn't feeling adventurous.

Comment at: test/CodeGenCXX/microsoft-abi-structors.cpp:42
@@ -64,1 +41,3 @@
+    // The deleting dtor is installed in the vtable and deferred to the end of
+    // the TU.
Timur Iskhodzhanov wrote:
> I don't like that the CHECKs are so far away from the code.
> Is it possible to just add some extra DTORS line before the first one that was here?
> e.g. add
>   void last_function_in_TU() {}
> at the end of the file?
I believe I got rid of DTORS because deferred code isn't emitted in source order anyway.  Now that we have more than one deferred code blob, they have to be in reverse source order, so you can't keep the CHECK with the source unless you start adding more FileCheck invocations.  Multiple FileCheck invocations are slow.

Comment at: lib/CodeGen/CodeGenModule.cpp:522
@@ +521,3 @@
+  // to each other, bottoming out with the base dtor, which might be external.
+  if (getTarget().getCXXABI().isMicrosoft() && isa<CXXDestructorDecl>(D) &&
+      GD.getDtorType() != Dtor_Base)
Timur Iskhodzhanov wrote:
> how about getDestructorLinkage added to GCXXABI ?
Yes, or something like hasLinkOnceDestructorVariants() here and below.


More information about the cfe-commits mailing list