[all-commits] [llvm/llvm-project] 8eac5d: [lld-macho] Reorganize + extend ICF test

Jez Ng via All-commits all-commits at lists.llvm.org
Fri Jul 23 08:49:22 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8eac5dcb36ddbb66dff467eda3fc0eee31d73631
      https://github.com/llvm/llvm-project/commit/8eac5dcb36ddbb66dff467eda3fc0eee31d73631
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    M lld/test/MachO/icf.s

  Log Message:
  -----------
  [lld-macho] Reorganize + extend ICF test

I found icf.s a bit hard to work with as it was not possible to
extend any of the functions `_a` ... `_k` to test new relocation /
referent types without modifying every single one of them. Additionally,
their one-letter names were not descriptive (though the comments
helped).

I've renamed all the functions to reflect the feature they are testing,
and shrunk them so that they contain just enough to test that one
feature.

I've also added tests for non-zero addends (via the
`_abs1a_ref_with_addend` and `_defined_ref_with_addend_1` functions).

Reviewed By: #lld-macho, gkm

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


  Commit: 3313b84481f3caa36cee3071d1379f8b9a028715
      https://github.com/llvm/llvm-project/commit/3313b84481f3caa36cee3071d1379f8b9a028715
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    M lld/MachO/ICF.cpp

  Log Message:
  -----------
  [lld-macho] ICF: Do more work in equalsConstant, less in equalsVariable

In particular, relocations to absolute symbols or literal sections can
be handled in equalsConstant(), since their output addresses will not
change across each iteration of ICF. Offsets and addends can also be
dealt with entirely in equalsConstant(), making the code somewhat easier
to reason about. Only ConcatInputSections need to be handled in
equalsVariable().

LLD-ELF's implementation takes a similar approach.

Although this should make ICF do less work, in practice it seems like
there is no stat sig difference in time taken when linking
chromium_framework.

This refactor is motivated by an upcoming diff which improves ICF's handling of
addends.

Reviewed By: #lld-macho, gkm

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


  Commit: cafed6f2923c63410450e80fc8cf1bbc8b63d708
      https://github.com/llvm/llvm-project/commit/cafed6f2923c63410450e80fc8cf1bbc8b63d708
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    M lld/test/MachO/common-symbol-resolution.s
    M lld/test/MachO/weak-definition-direct-fetch.s

  Log Message:
  -----------
  [lld-macho][nfc] Fix test to reflect that symbol attributes don't matter within an archive

We had a comment that claimed that defined symbols had priority
over common symbols if they occurred in the same archive. In fact, they
appear to have equal precedence. Our implementation already does this,
so I'm just updating the test comment. Also added a few other test
comments along the way for readability.

Reviewed By: #lld-macho, thakis

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


  Commit: d9a639901f8940a979cae6c501c21890e5da07cd
      https://github.com/llvm/llvm-project/commit/d9a639901f8940a979cae6c501c21890e5da07cd
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    A lld/test/MachO/lto-symbol-resolution.ll

  Log Message:
  -----------
  [lld-macho][nfc] Add test for resolution of bitcode symbols

We lacked a test for bitcode symbol precedence. We assumed that
they followed the same rules as their regular symbol counterparts, but
never had a test to verify that we were matching ld64's behavior. It
turns out that we were largely correct, though we deviate from ld64 when
there are bitcode and non-bitcode symbols of the same name. The test
added in this diff both verifies our behavior and documents the
differences.

Reviewed By: #lld-macho, thakis

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


Compare: https://github.com/llvm/llvm-project/compare/0ad562b48bfd...d9a639901f89


More information about the All-commits mailing list