This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Only consider associated EH sections during ICF
ClosedPublic

Authored by rnk on Mar 19 2021, 4:40 PM.

Details

Summary

The only known reason why ICF should not merge otherwise identical
sections with differing associated sections has to do with exception
handling tables. It's not clear what ICF should do when there are other
kinds of associated sections. In every other case when this has come up,
debug info and CF guard metadata, we have opted to make ICF ignore the
associated sections.

For comparison, ELF doesn't do anything for comdat groups. Instead,
.eh_frame is parsed to figure out if a section has an LSDA, and if so,
ICF is disabled.

Another issue is that the order of associated sections is not defined.
We have had issues in the past where changing the order of the
.xdata/.pdata sections in the object file lead to large ICF slowdowns.

To address these issues, I decided it would be best to explicitly
consider only .pdata and .xdata sections during ICF. This makes it easy
to ignore the object file order, and I think it makes the intention of
the code clearer.

I've also made the children() accessor return an empty list for
associated sections. This mostly only affects ICF and GC. This was the
behavior before I made this a linked list, so the behavior change should
be good. This had positive effects on chrome.dll: more .xdata sections
were merged that previously could not be merged because they were
associated with distinct .pdata sections.

Diff Detail

Event Timeline

rnk requested review of this revision.Mar 19 2021, 4:40 PM
rnk created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2021, 4:40 PM
mstorsjo accepted this revision.Mar 20 2021, 6:40 AM

LGTM, this sounds sensible.

Would this have fixed the issue in https://bugs.chromium.org/p/chromium/issues/detail?id=1144476 ?

This revision is now accepted and ready to land.Mar 20 2021, 6:40 AM
rnk added a comment.Mar 22 2021, 3:00 PM

LGTM, this sounds sensible.

Would this have fixed the issue in https://bugs.chromium.org/p/chromium/issues/detail?id=1144476 ?

Yes, thanks, that's the issue I was referring to. :) I was away from my email when I wrote this, so I couldn't even dig it up to add to the description.

In D98993#2642758, @rnk wrote:

LGTM, this sounds sensible.

Would this have fixed the issue in https://bugs.chromium.org/p/chromium/issues/detail?id=1144476 ?

Yes, thanks, that's the issue I was referring to. :) I was away from my email when I wrote this, so I couldn't even dig it up to add to the description.

Ah, nice. :-)

I actually have a couple follow-up patches relating to when/where xdata/pdata are emitted - I think they should be safe wrt ICF but I didn't bother to risk anything back when I wrote them.

This revision was automatically updated to reflect the committed changes.

Gonna revert this for now--