This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Extend lto-internalize-unnamed-addr.ll
ClosedPublic

Authored by int3 on Mar 10 2022, 4:36 PM.

Details

Reviewers
modimo
Group Reviewers
Restricted Project
Commits
rGf5ddcf25d67f: [lld-macho] Extend lto-internalize-unnamed-addr.ll
Summary
  • Test the case where a symbol is sometimes linkonce_odr and sometimes weak_odr
  • Test the visibility of the symbols at the IR level, after the internalize stage of LTO is done. (Previously we only checked the visibility of symbols in the final output binary.)

Diff Detail

Event Timeline

int3 created this revision.Mar 10 2022, 4:36 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 10 2022, 4:36 PM
int3 requested review of this revision.Mar 10 2022, 4:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2022, 4:36 PM
modimo added inline comments.
lld/test/MachO/lto-internalize-unnamed-addr.ll
28

thinlto+dylib shares the same output as thinlto by itself. Can check for that as well in the bitcode output

49

I find it odd that local_unnamed is able to be internalized in fullLTO but not thinLTO. The code path is https://github.com/llvm/llvm-project/blob/9f616a467fc710f084b7e57812a2ed64c214c2c6/llvm/lib/LTO/LTO.cpp#L349 where any linkonce_odr gets upgraded to weak but if this is the only copy that exists it appears to fit within the rules coming from D20348. cc @tejohnson is there an opportunity here?

70

Add final output binary check for LTO-DAG and THINLTO-DAG as well?

int3 updated this revision to Diff 415150.Mar 14 2022, 10:23 AM
int3 marked 2 inline comments as done.

update

lld/test/MachO/lto-internalize-unnamed-addr.ll
49

I realize global_unnamed_sometimes_linkonce has the same issue too. I've added a FIXME for this

70

whoops, yeah. missed this

tejohnson added inline comments.Mar 14 2022, 10:26 AM
lld/test/MachO/lto-internalize-unnamed-addr.ll
49

That's true, if there is only one copy no need to make the prevailing one weak_odr. Is changing that sufficient to get the internalization in the ThinLTO case?

int3 added inline comments.Mar 15 2022, 1:51 PM
lld/test/MachO/lto-internalize-unnamed-addr.ll
49

I tried https://gist.github.com/int3/b66de20462da71e8757e09bacfc361ca but that just seems to result in global_unnamed and local_unnamed_const no longer being marked as hidden...

tejohnson added inline comments.Mar 15 2022, 2:07 PM
lld/test/MachO/lto-internalize-unnamed-addr.ll
49

To get hidden back this would need to be adjusted accordingly to handle linkonce_odr:
http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#980

int3 marked an inline comment as done.Mar 15 2022, 5:23 PM
int3 added inline comments.
lld/test/MachO/lto-internalize-unnamed-addr.ll
49

ah gotcha. yeah I got the hiddens back after changing that, as well as removing this earlier condition: http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#952

A bunch of check-llvm tests are now failing though. I would like to go through them at some point and figure out if they're legit, but I'd like to focus on other aspects of LLD for now. @modimo do you mind stamping this first?

modimo accepted this revision.Mar 16 2022, 12:16 PM
modimo added inline comments.
lld/test/MachO/lto-internalize-unnamed-addr.ll
49

Sure.

This revision is now accepted and ready to land.Mar 16 2022, 12:16 PM
This revision was automatically updated to reflect the committed changes.
int3 marked an inline comment as done.