This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Fold cfstrings with --deduplicate-literals
ClosedPublic

Authored by keith on Jul 19 2022, 5:11 PM.

Details

Reviewers
int3
Group Reviewers
Restricted Project
Commits
rG15f685eaa886: [lld-macho] Fold cfstrings with --deduplicate-literals
Summary

Similar to cstrings ld64 always deduplicates cfstrings. This was already
being done when enabling ICF, but for debug builds you may want to flip
this on if you cannot eliminate your instances of this, so this change
makes --deduplicate-literals also apply to cfstrings.

Diff Detail

Event Timeline

keith created this revision.Jul 19 2022, 5:11 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 19 2022, 5:11 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
keith requested review of this revision.Jul 19 2022, 5:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 5:11 PM
keith added a comment.Jul 19 2022, 5:12 PM

Here's a repro case where this causes issues https://github.com/tapthaker/lld-reproducer, very similar to the standard cstring cases.

lld/MachO/ICF.cpp
398

I'm not happy with hijacking this function for this specific use case, so it would probably make sense for me to try to extract something here

int3 accepted this revision.Jul 19 2022, 6:27 PM
int3 added a subscriber: int3.

lgtm

lld/MachO/Driver.cpp
1669–1671

this is the more typical codebase convention

lld/MachO/ICF.cpp
398

yeah that would be nice but no rush

lld/test/MachO/cfstring-dedup.s
40–51

isn't this identical to the CHECK lines above? don't think we need to define a separate CHECK prefix

This revision is now accepted and ready to land.Jul 19 2022, 6:27 PM
keith updated this revision to Diff 446166.Jul 20 2022, 8:13 AM
keith marked 2 inline comments as done.

style fixes, use single new prefix in test

lld/MachO/ICF.cpp
398

Ok thanks, we can see how this evolves a bit then I guess

lld/test/MachO/cfstring-dedup.s
40–51

So this part is, but the first CHECK block isn't valid for this codepath, since it expects TEXT,text folding as well. I've combined these to avoid the duplication and pointed the original test to both prefixes, wdyt?

int3 added inline comments.Jul 20 2022, 11:05 AM
lld/test/MachO/cfstring-dedup.s
40–51

oh right. Yeah, this is a good solution, thanks!

This revision was automatically updated to reflect the committed changes.