This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Flip string deduplication default
ClosedPublic

Authored by keith on Dec 21 2022, 3:54 PM.

Details

Reviewers
MaskRay
int3
Group Reviewers
Restricted Project
Commits
rG2e5989e8140d: [lld-macho] Flip string deduplication default
Summary

Previously by default, when not using --ifc=, lld would not
deduplicate string literals. This reveals reliance on undefined behavior
where string literal addresses are compared instead of using string
equality checks. While ideally you would be able to easily identify and
eliminate the reliance on this UB, this can be difficult, especially for
third party code, and increases the friction and risk of users migrating
to lld. This flips the default to deduplicate strings unless
--no-deduplicate-strings is passed, matching ld64's behavior.

Diff Detail

Event Timeline

keith created this revision.Dec 21 2022, 3:54 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a subscriber: arphaman. · View Herald Transcript
keith requested review of this revision.Dec 21 2022, 3:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2022, 3:54 PM
int3 added a subscriber: int3.Dec 22 2022, 1:19 PM

Thanks for doing this!

lld/MachO/InputFiles.cpp
345–346

since we're deduping all word literals unconditionally now, we should hoist line 362 into its own if block & not gate it on config->dedupStrings. And I guess if we find any relocations in literal sections we should just error out unconditionally.

lld/MachO/Options.td
61

Is comparing string pointers actually undefined, or just not what the code author intended?

lld/MachO/Writer.cpp
1329

make unconditional

keith updated this revision to Diff 484956.Dec 22 2022, 1:38 PM
keith marked 3 inline comments as done.

Remove literal deduping

lld/MachO/Options.td
61

Through the previous convos it sounded like it was UB but I can't find another source on that so I reworded.

int3 accepted this revision.Dec 22 2022, 3:18 PM

lgtm

This revision is now accepted and ready to land.Dec 22 2022, 3:18 PM
This revision was automatically updated to reflect the committed changes.