On 01/19/2017 10:26 AM, Jan Hubicka wrote:

2) For LDPR_PREVAILING_DEF members we don't make_decl_local, but instead
clear DECL_COMDAT and DECL_WEAK.  Thus forcing this decl to be the
prevailing decl in the final link

3) For decls we localize, we also clear node->externally_visible and
node->force_by_abi.  That matches the behavior for the decl of interest too
and will clue the wpa partitioning logic into knowing it needs to
hidden-externalize the decl.

So at the moment it works in a way
 1) we walk first symbol of the comdat and it is LDPR_PREVAILING_DEF and thus
    we set externall visible flag
 2) we walk second symbol of the comdat and it is LDPR_PREVAILING_DEF_IRONLY
    and thus we decide to privatize the whole comdat group, during this
    process we force the first symbol local and clear the externally_visible
    flag?

Nearly correct. We attempt to do #2 but we fail to clear node->externally_visible (but we do update DECL_PUBLIC). Thus the PREVAILING_DEF symbol is in an inconsistent state (which is what confused the partitioning logic).

I think at a time we decide on external visibility of a symbol in a comdat
group, we need to check that the comdat group as a whole is not exporte (i.e.
no LDPR_PREVAILING_DEF_EXP or incremental linking).  Then we know we can 
dissolve
the comdat group (without actually affecting visibility) and then we can
handle each symbol independently.

Could be. I did consider splitting this loop into two (which I think is an outcome of what you suggest) -- one that set each nodes external_visiblilty as desired and the a second loop that did the processing.

It also occurs to me that if we did that we'd need to process the vardecls in a similar order. I.e. go from the current:

foreach FN
  determine visibility
  adjust decl/break comdat
for each VAR
  determine visibility
  adjust decl/break comdat

to
foreach FN
  determine visibility
foreach VAR
  determine visibility
foreach FN
  adjust decl/maybe break comdat
foreach VAR
  adjust decl/maybe break comdat

nathan
--
Nathan Sidwell

Reply via email to