[all-commits] [llvm/llvm-project] 6503a6: [lld/mac] Don't assert when ICFing arm64 code

Nico Weber via All-commits all-commits at lists.llvm.org
Wed Oct 27 11:02:29 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6503a68565f6ba4e13935ee614a732b6fcb2b30b
      https://github.com/llvm/llvm-project/commit/6503a68565f6ba4e13935ee614a732b6fcb2b30b
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M lld/MachO/InputSection.cpp
    M lld/MachO/SyntheticSections.h
    A lld/test/MachO/icf-arm64.s

  Log Message:
  -----------
  [lld/mac] Don't assert when ICFing arm64 code

WordLiteralSection dedupes literals by content.
WordLiteralInputSection::getOffset() used to read a literal at the passed-in
offset and look up this value in the deduping map to find the offset of the
deduped value.

But it's possible that (e.g.) a 16-byte literal's value is accessed 4 bytes in.
To get the offset at that address, we have to get the deduped value at offset 0
and then apply the offset 4 to the result.

(See also WordLiteralSection::finalizeContents() which fills in those maps.)

Only a problem on arm64 because in x86_64 the offset is part of the instruction
instead of a separate ARM64_RELOC_ADDEND relocation. (See bug for more details.)

Fixes PR51999.

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




More information about the All-commits mailing list