This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Consolidate all priority assignments under `buildInputSectionPriorities()`
AbandonedPublic

Authored by Roger on Mar 24 2022, 1:45 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

The previous code assigned priorities for sections across different call stacks from Driver.cpp. The data gathered to assign priorities seems to be spread across different call stacks by necessity (test fails when I try to put them all together). However, the actual priority assignments do not need to be. After all of the relevant data has been collected, we can make all the priority assignments under one function (ie, buildInputSectionPriorities()) specific for that purpose. This is the change for this diff.

This diff is almost completely a NFC but there is one slight functional change that I believe corrects a bug. The existing code for extractCallGraphProfile() filters data about calls from or to symbols that already has a priority (based on the order file). There are two ways for a symbol to have a priority at that point in time:

  1. The symbol is specifically referenced by name and its order file in the order file.
  2. The symbol is indirectly referenced by an entry in the order file that contains its name but specifies no order file.

If two order files each have a symbol using the same name and the order file includes one of the symbols (specifying its order file), the existing code produced a side effect of giving all symbols of the same name a default priority of zero. Having a priority of zero is not the same as having no priority at all as now those symbols with default priority zero will have their calls ignored by extractCallGraphProfile().

My diff changes this behavior so that an entry in the order file for one symbol in a specific object file will have no effect on the priority of symbols with the same name in other object files.

Diff Detail

Event Timeline

Roger created this revision.Mar 24 2022, 1:45 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 24 2022, 1:45 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Roger retitled this revision from [lld-macho][NFC] Bring together all priority assignments into one place. to [lld-macho] Consolidate all priority assignments under `buildInputSectionPriorities()`.Mar 24 2022, 8:51 PM
Roger edited the summary of this revision. (Show Details)
Roger updated this revision to Diff 418242.Mar 25 2022, 8:49 AM

add comment

Roger edited the summary of this revision. (Show Details)Mar 28 2022, 1:08 PM
Roger updated this revision to Diff 418732.Mar 28 2022, 4:49 PM

Ready for review

lld/MachO/SectionPriorities.cpp
323–325

honestly, this condition feels a little weird to me because this boolean can short circuit the expression and skip checking for symbol priority, but this also skips checking if the symbol is absolute/not.

I'm just retaining the existing logic, but I question the correctness of the existing logic.

Roger published this revision for review.Mar 28 2022, 4:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2022, 4:50 PM
Roger planned changes to this revision.Mar 29 2022, 2:14 PM
Roger added a subscriber: int3.

After having spoken to @int3 , we decided to adjust the code in a couple ways so I'll be reworking this diff.

Roger abandoned this revision.Apr 19 2022, 12:49 PM