This is an archive of the discontinued LLVM Phabricator instance.

Don't dllimport/export destructor variants implemented by thunks.
ClosedPublic

Authored by hans on May 27 2014, 2:47 PM.

Details

Summary

MSVC doesn't export these functions, so trying to import them doesn't work.
Also, don't let any dll attributes on the CXXDestructorDecl influence the
thunk's linkage -- it should always be linkonce_odr.

This takes care of the FIXME's for this in Nico's tests.

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 9849.May 27 2014, 2:47 PM
hans retitled this revision from to Don't dllimport/export destructor variants implemented by thunks..
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added reviewers: rnk, nrieck.
hans added subscribers: Unknown Object (MLST), hansw.
ygao added a subscriber: ygao.May 27 2014, 3:16 PM
rnk added inline comments.May 27 2014, 3:24 PM
lib/CodeGen/CodeGenModule.cpp
1396–1397 ↗(On Diff #9849)

This belongs after the call to setLinkageAndVisibilityForGV() in CodeGenModule::SetFunctionAttributes(), to keep all the dllstorage class code closer together.

1925 ↗(On Diff #9849)

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.

hans added inline comments.May 27 2014, 3:57 PM
lib/CodeGen/CodeGenModule.cpp
1396–1397 ↗(On Diff #9849)

Done.

1925 ↗(On Diff #9849)

Done.

hans updated this revision to Diff 9850.May 27 2014, 3:57 PM

Addressing Reid's comments.

rnk accepted this revision.May 27 2014, 6:23 PM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.May 27 2014, 6:23 PM
hans closed this revision.May 27 2014, 7:00 PM
hans updated this revision to Diff 9858.

Closed by commit rL209706 (authored by @hans).