This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][nfc] Simplify LC_DATA_IN_CODE generation
ClosedPublic

Authored by int3 on Dec 10 2021, 2:57 PM.

Details

Reviewers
thakis
ributzka
Group Reviewers
Restricted Project
Commits
rG098430cd25e7: [lld-macho][nfc] Simplify LC_DATA_IN_CODE generation
Summary
  1. After D113241, we have the section address easily accessible and no longer need to iterate across the LC_SEGMENT commands to emit LC_DATA_IN_CODE.
  1. There's no need to store a pointer to the data in code entries during the parse step; we can just look it up as part of the output step.

Diff Detail

Event Timeline

int3 created this revision.Dec 10 2021, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 2:57 PM
int3 requested review of this revision.Dec 10 2021, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 2:57 PM
thakis accepted this revision.Dec 10 2021, 6:23 PM
thakis added a subscriber: thakis.

LG

This revision is now accepted and ready to land.Dec 10 2021, 6:23 PM
This revision was automatically updated to reflect the committed changes.
BertalanD added inline comments.
lld/MachO/SyntheticSections.cpp
745–748

This assert seems to check a different thing than the one that was in ObjFile::parseInDataCode. Here, dataInCodeEntries contains the final contents of the DataInCodeSection, we should be checking entries instead, which contains the data from the object file.

This assertion will fail if sections are reordered because of PGO; it just happens to work in the usual case, because sections are output in the order they are present in the input files.

Here is such a failure during a PGO bootstrapping build of LLVM on x86_64: https://ci.chromium.org/ui/p/chromium/builders/try/mac_upload_clang/2582/overview

(Or if we need to keep the entries sorted, we can't just add them in the order they appear in inputFiles)

I'm happy to fix this.

Herald added a project: Restricted Project. · View Herald Transcript
thakis added inline comments.Sep 9 2022, 12:07 PM
lld/MachO/SyntheticSections.cpp
745–748

Fix for this is in D133581.