.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.
I would elaborate: If sym is not otherwise referenced or defined anywhere else in the file, this directive is a no-op.