[PATCH] Don't dllimport/export destructor variants implemented by thunks.

Reid Kleckner rnk at google.com
Tue May 27 15:24:08 PDT 2014


================
Comment at: lib/CodeGen/CodeGenModule.cpp:1396-1397
@@ -1395,1 +1395,4 @@
 
+  if (const auto *Dtor = dyn_cast_or_null<CXXDestructorDecl>(D)) {
+    if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) {
+      // Don't dllexport/import destructor thunks.
----------------
This belongs after the call to setLinkageAndVisibilityForGV() in CodeGenModule::SetFunctionAttributes(), to keep all the dllstorage class code closer together.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:1925
@@ -1917,3 +1924,3 @@
     const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable,
     bool UseThunkForDtorVariant) {
   if (Linkage == GVA_Internal)
----------------
I don't like how this hyper-specific bool got threaded all the way into getLLVMLinkageForDeclarator in r207451.  I think with this change we can handle dtor thunks as a special case in CodeGenModule::getFunctionLinkage() with something like:

  if (isa<CXXDestructorDecl>(D) &&
      getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D),
                                         GD.getDtorType())) {
    return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
                                   : llvm::GlobalValue::LinkOnceODRLinkage;
  }

I don't think having the 'weak' attribute on a dtor should affect the linkage of its thunks.

http://reviews.llvm.org/D3930






More information about the cfe-commits mailing list