[all-commits] [llvm/llvm-project] 853583: [lld-macho][nfc] Misc code cleanup

Jez Ng via All-commits all-commits at lists.llvm.org
Tue May 25 11:58:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8535834ef7891a5221e0bd1350a4f0636b6f3efb
      https://github.com/llvm/llvm-project/commit/8535834ef7891a5221e0bd1350a4f0636b6f3efb
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputSection.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h

  Log Message:
  -----------
  [lld-macho][nfc] Misc code cleanup

* Move `static_asserts` into cpp instead of header file. I noticed they
  had been separated from the main class definition in the header, so I
  set about to clean that up, then figured it made more sense as part of
  the cpp file so as not to incur unnecessary compile-time overhead.

* Remove unnecessary `virtual`s

* Remove unnecessary comment / reword another comment


  Commit: 9cc0d893f7fc4d0ed5dfb053bc38cab832f2f88f
      https://github.com/llvm/llvm-project/commit/9cc0d893f7fc4d0ed5dfb053bc38cab832f2f88f
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M lld/MachO/SyntheticSections.h
    M lld/MachO/UnwindInfoSection.cpp

  Log Message:
  -----------
  [lld-macho][nfc] clang-format everything


  Commit: 33706191d88d34382e07c48ff09fe639fae5881d
      https://github.com/llvm/llvm-project/commit/33706191d88d34382e07c48ff09fe639fae5881d
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M lld/MachO/CMakeLists.txt
    A lld/MachO/ConcatOutputSection.cpp
    A lld/MachO/ConcatOutputSection.h
    R lld/MachO/MergedOutputSection.cpp
    R lld/MachO/MergedOutputSection.h
    M lld/MachO/OutputSection.h
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/Symbols.cpp
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/UnwindInfoSection.h
    M lld/MachO/Writer.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Rename MergedOutputSection to ConcatOutputSection

The ELF format has the concept of merge sections (marked by SHF_MERGE),
which contain data that can be safely deduplicated. The Mach-O
equivalents are called literal sections (marked by S_CSTRING_LITERALS or
S_{4,8,16}BYTE_LITERALS). While the Mach-O format doesn't use the word
'merge', to avoid confusion, I've renamed our MergedOutputSection to
ConcatOutputSection. I believe it's a more descriptive name too.

This renaming sets the stage for {D102964}.

Reviewed By: #lld-macho, alexshap

Differential Revision: https://reviews.llvm.org/D102971


  Commit: fcab06bd85d142eb715b5b96997a24247002e753
      https://github.com/llvm/llvm-project/commit/fcab06bd85d142eb715b5b96997a24247002e753
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M lld/MachO/OutputSection.h
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/OutputSegment.h
    M lld/MachO/Writer.cpp
    M lld/test/MachO/load-command-sequence.s
    A lld/test/MachO/section-order.s
    M lld/test/MachO/weak-binding.s

  Log Message:
  -----------
  [lld-macho][nfc] Sort OutputSections based on explicit order of command-line inputs

This diff paves the way for {D102964} which adds a new kind of
InputSection.

We previously maintained section ordering implicitly: we created
InputSections as we parsed each file in command-line order, and passed
on this ordering when we created OutputSections and OutputSegments by
iterating over these InputSections. The implicitness of the ordering
made it difficult to refactor the code to e.g. handle a new type of
InputSection. As such, I've codified the ordering explicitly via
`inputOrder` fields. This also allows us to use `sort` instead of
`stable_sort`.

Benchmarking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W:

      N           Min           Max        Median           Avg        Stddev
  x  20          4.23          4.35          4.27         4.274   0.030157481
  +  20          4.24          4.38          4.27        4.2815   0.033759989
  No difference proven at 95.0% confidence

Reviewed By: #lld-macho, alexshap

Differential Revision: https://reviews.llvm.org/D102972


  Commit: 7599e98ab7904dce34ea208009f00e87d9d965fb
      https://github.com/llvm/llvm-project/commit/7599e98ab7904dce34ea208009f00e87d9d965fb
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/OutputSegment.h
    M lld/MachO/Writer.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Remove unnecessary parameterization of section sort

As @alexshap pointed out [here](https://reviews.llvm.org/D102972#inline-975208),
it's a bit confusing to have the option to sort OutputSections with any
comparator when in practice we only use one.

Reviewed By: #lld-macho, alexshap, thakis

Differential Revision: https://reviews.llvm.org/D102974


Compare: https://github.com/llvm/llvm-project/compare/d1e5f046cc9c...7599e98ab790


More information about the All-commits mailing list