[all-commits] [llvm/llvm-project] b2a073: [lld-macho][nfc] Remove InputSection::outSecFileOff

Jez Ng via All-commits all-commits at lists.llvm.org
Sun Jun 13 16:52:27 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b2a0739012163f5433c0f069e842ee4cea3100f7
      https://github.com/llvm/llvm-project/commit/b2a0739012163f5433c0f069e842ee4cea3100f7
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-06-13 (Sun, 13 Jun 2021)

  Changed paths:
    M lld/MachO/ConcatOutputSection.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h
    M lld/MachO/Symbols.cpp
    M lld/MachO/Symbols.h
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/Writer.cpp

  Log Message:
  -----------
  [lld-macho][nfc] Remove InputSection::outSecFileOff

`outSecFileOff` and the associated `getFileOffset()` accessors were
unnecessary.

For all the cases we care about, `outSecFileOff` is the same as
`outSecOff`. The only time they deviate is if there are zerofill
sections within a given segment. But since zerofill sections are always
at the end of a segment, the only sections where the two values deviate
are zerofill sections themselves. And we never actually query the
outSecFileOff of zerofill sections.

As for `getFileOffset()`, the only place it was being used was to
calculate the offset of the entry symbol. However, we can compute that
value by just taking the difference between the address of the entry
symbol and the address of the Mach-O header. In fact, this appears to be
what ld64 itself does. This difference is the same as the file offset as
long as there are no intervening zerofill sections, but since `__text`
is the first section in `__TEXT`, this never happens, so our previous
use of `getFileOffset()` was not wrong -- just inefficient.

Reviewed By: #lld-macho, thakis

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


  Commit: c5c05ffa4562223cae7db537ca7772afaeccd009
      https://github.com/llvm/llvm-project/commit/c5c05ffa4562223cae7db537ca7772afaeccd009
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-06-13 (Sun, 13 Jun 2021)

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

  Log Message:
  -----------
  [lld-macho][nfc] Represent the image loader cache with a ConcatInputSection

We don't need to define any special behavior for this section,
so creating a subclass for it is redundant.

Reviewed By: #lld-macho, thakis

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


  Commit: da24e6d43e3fdc07aa84f55b35ec50f6b96545ad
      https://github.com/llvm/llvm-project/commit/da24e6d43e3fdc07aa84f55b35ec50f6b96545ad
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-06-13 (Sun, 13 Jun 2021)

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

  Log Message:
  -----------
  [lld-macho][nfc] Add `final` to classes where possible

I wanted to see if we would get any perf wins out of this, but
it doesn't seem to be the case. But it still seems worth committing.

Reviewed By: MaskRay

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


Compare: https://github.com/llvm/llvm-project/compare/f09e200b31f4...da24e6d43e3f


More information about the All-commits mailing list