[PATCH] D135642: [MC] .addrsig_sym: ignore unregistered symbols

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 20:47:36 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: rnk, tejohnson.
Herald added subscribers: StephenFan, dmgreen, hiraditya, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

.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; }` produces undefined x only in `-O0 -faddrsig`, not other combos of -O and -fno-addrsig
- 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 <https://reviews.llvm.org/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 <https://reviews.llvm.org/D101512> (`isTransitiveUsedByMetadataOnly`) but the increased
`OutStreamer->emitAddrsigSym(getSymbol(&GV));` complexity makes me nervous.
Just ignoring unregistered symbols circumvents the problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135642

Files:
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/MC/COFF/addrsig.s
  llvm/test/MC/ELF/addrsig-error.s
  llvm/test/MC/ELF/addrsig.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135642.466693.patch
Type: text/x-patch
Size: 4139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221011/563495db/attachment.bin>


More information about the llvm-commits mailing list