This is an archive of the discontinued LLVM Phabricator instance.

Emit initializers for selectany globals in comdat-associative sections (PR20889)
ClosedPublic

Authored by hans on Sep 9 2014, 5:21 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 13505.Sep 9 2014, 5:21 PM
hans retitled this revision from to Emit initializers for selectany globals in comdat-associative sections (PR20889).
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added reviewers: rnk, majnemer.
hans added subscribers: Unknown Object (MLST), hansw.
rnk added inline comments.Sep 9 2014, 8:22 PM
lib/CodeGen/CGDeclCXX.cpp
335 ↗(On Diff #13505)

Should we do the same for WeakAttr? What does GCC do?

I wonder if there is a more general GVA linkage check we should do. Can you add a test for static data members of implicitly instantiated dllexport class templates?

hans added inline comments.Sep 10 2014, 10:12 AM
lib/CodeGen/CGDeclCXX.cpp
335 ↗(On Diff #13505)

Yes, doing the same for WeakAttr sounds reasonable.

I couldn't observe gcc doing anything special for dynamic initializers of weak objects :/

We do get this right for static data members of implicitly instantiated class templates; it's handled by your code above, and dllexport doesn't change it. I can add a test.

If we want to base this on GVA linkage, it seems to me that the associative comdat method should be applied to all symbols that can be merged, so GVA_StrongODR and GVA_DiscardableODR? But I don't think SelectAny or WeakAttr are reflected in the gva linkage.

rnk accepted this revision.Sep 10 2014, 11:33 AM
rnk edited edge metadata.

lgtm

lib/CodeGen/CGDeclCXX.cpp
335 ↗(On Diff #13505)

I *think* selectany and templates are the only ways to get COMDAT data with dynamic initialization, so we should be OK with what we have then.

This revision is now accepted and ready to land.Sep 10 2014, 11:33 AM
hans closed this revision.Sep 10 2014, 12:38 PM
hans updated this revision to Diff 13555.

Closed by commit rL217534 (authored by @hans).