This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Don't assert when ICFing arm64 code
ClosedPublic

Authored by thakis on Oct 26 2021, 5:34 PM.

Details

Reviewers
gkm
int3
Group Reviewers
Restricted Project
Commits
rG6503a68565f6: [lld/mac] Don't assert when ICFing arm64 code
Summary

WordLiteralSection dedupes literals by content.
WordLiteralInputSection::getOffset() used to read a literal at the passed-in
offset and look up this value in the deduping map to find the offset of the
deduped value.

But it's possible that (e.g.) a 16-byte literal's value is accessed 4 bytes in.
To get the offset at that address, we have to get the deduped value at offset 0
and then apply the offset 4 to the result.

(See also WordLiteralSection::finalizeContents() which fills in those maps.)

Only a problem on arm64 because in x86_64 the offset is part of the instruction
instead of a separate ARM64_RELOC_ADDEND relocation. (See bug for more details.)

Fixes PR51999.

Diff Detail

Event Timeline

thakis created this revision.Oct 26 2021, 5:34 PM
Herald added a project: Restricted Project. · View Herald Transcript
thakis requested review of this revision.Oct 26 2021, 5:34 PM

Ping, quick 3-line crash fix :)

Takes size of an arm64 Chromium Framework from 238M without --icf=all to 225M with it (compared to 235M with ld64).

int3 accepted this revision.Oct 27 2021, 10:58 AM
int3 added a subscriber: int3.

Nice, thanks!

This revision is now accepted and ready to land.Oct 27 2021, 10:58 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2021, 11:02 AM