[PATCH] D115556: [lld-macho][nfc] Simplify LC_DATA_IN_CODE generation

Daniel Bertalan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 08:10:26 PDT 2022


BertalanD added inline comments.
Herald added a reviewer: ributzka.
Herald added a project: All.


================
Comment at: lld/MachO/SyntheticSections.cpp:745-748
+    assert(is_sorted(dataInCodeEntries, [](const data_in_code_entry &lhs,
+                                           const data_in_code_entry &rhs) {
+      return lhs.offset < rhs.offset;
+    }));
----------------
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115556/new/

https://reviews.llvm.org/D115556



More information about the llvm-commits mailing list