This is an archive of the discontinued LLVM Phabricator instance.

MS ABI: Generate default constructor closures
ClosedPublic

Authored by majnemer on Mar 13 2015, 2:47 PM.

Details

Summary

The MS ABI utilizes a compiler generated function called the "vector
constructor iterator" to construct arrays of objects with
non-trivial constructors/destructors. For this to work, the constructor
must follow a specific calling convention. A thunk must be created if
the default constructor has default arguments, is variadic or is
otherwise incompatible. This thunk is called the default constructor
closure.

N.B. Default constructor closures are only generated if the default
constructor is exported because clang itself does not utilize vector
constructor iterators. Failing to export the default constructor
closure will result in link/load failure if a translation unit compiled
with MSVC is on the import side.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 21960.Mar 13 2015, 2:47 PM
majnemer retitled this revision from to MS ABI: Generate default constructor closures.
majnemer updated this object.
majnemer added reviewers: rnk, hansw.
majnemer added a subscriber: Unknown Object (MLST).
hans added a subscriber: hans.Mar 13 2015, 3:09 PM
hans added inline comments.
lib/AST/MicrosoftMangle.cpp
1647 ↗(On Diff #21960)

This changes from "XX@Z" to "XXZ" for the Ctor_DefaultClosure case. Just double checking that that's intended.

lib/CodeGen/CodeGenTypes.h
268 ↗(On Diff #21960)

nit: indent is off?

test/CodeGenCXX/dllexport.cpp
496 ↗(On Diff #21960)

Add a test where dllexport is on the class rather than the member?

majnemer added inline comments.Mar 13 2015, 3:14 PM
lib/AST/MicrosoftMangle.cpp
1647 ↗(On Diff #21960)

Yep.

lib/CodeGen/CodeGenTypes.h
268 ↗(On Diff #21960)

Will do.

test/CodeGenCXX/dllexport.cpp
496 ↗(On Diff #21960)

Will do.

majnemer updated this revision to Diff 21965.Mar 13 2015, 3:24 PM
  • Address Hans' review feedback.
rnk accepted this revision.Mar 13 2015, 3:27 PM
rnk edited edge metadata.

lgtm

lib/CodeGen/MicrosoftCXXABI.cpp
1073–1077 ↗(On Diff #21960)

Can we wrap up the calling convention comparison test into a helper with a name like hasDefaultCXXMethodCC()?

lib/Sema/SemaDecl.cpp
12088 ↗(On Diff #21960)

Let's pull this loop out into a static helper.

This revision is now accepted and ready to land.Mar 13 2015, 3:27 PM
hans accepted this revision.Mar 13 2015, 3:29 PM
hans added a reviewer: hans.
hans added inline comments.
lib/CodeGen/CodeGenTypes.h
268 ↗(On Diff #21965)

indent still looks off in Phabricator

This revision was automatically updated to reflect the committed changes.