[all-commits] [llvm/llvm-project] d8162a: [MC] .addrsig_sym: ignore unregistered symbols

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Oct 11 15:07:30 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d8162a7196b3916d3bb51b2597c9e417e4132150
      https://github.com/llvm/llvm-project/commit/d8162a7196b3916d3bb51b2597c9e417e4132150
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-10-11 (Tue, 11 Oct 2022)

  Changed paths:
    M llvm/docs/Extensions.rst
    M llvm/lib/MC/ELFObjectWriter.cpp
    M llvm/lib/MC/MCObjectStreamer.cpp
    M llvm/lib/MC/MachObjectWriter.cpp
    M llvm/lib/MC/WinCOFFObjectWriter.cpp
    M llvm/test/MC/COFF/addrsig.s
    R llvm/test/MC/ELF/addrsig-error.s
    M llvm/test/MC/ELF/addrsig.s
    M llvm/test/MC/MachO/addrsig.s

  Log Message:
  -----------
  [MC] .addrsig_sym: ignore unregistered symbols

.addrsig_sym forces registering the symbol regardless whether it is otherwise
registered. This creates an undefined symbol which is inconvenient/undesired:

* `extern int x; void f() { (void)x; }` has inconsistent behavior whether `x` is emitted as an undefined symbol.
  `-O0 -faddrsig` makes `x` undefined while other -O levels and -fno-addrsig eliminate the symbol.
* In ThinLTO, after a non-prevailing linkonce_odr definition is converted to available_externally, and then a declaration,
  the addrsig code emits a symbol while the symbol is otherwise unseen.

D135427 fixed a bug that a non-prevailing `__cxx_global_var_init` was
incorrectly retained. However, the IR declaration causes an undesired
`.addrsig_sym __cxx_global_var_init`. This can be addressed in a way similar
to D101512 (`isTransitiveUsedByMetadataOnly`) but the increased
`OutStreamer->emitAddrsigSym(getSymbol(&GV));` complexity makes me nervous.
Just ignoring unregistered symbols circumvents the problem.

Reviewed By: rnk

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




More information about the All-commits mailing list