[llvm] [IR] llvm.reloc.none intrinsic for no-op symbol references (PR #147427)

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 14:52:57 PST 2025


mysterymath wrote:

>From @ilovepi:
> In particular, I see @MaskRay had a question that seems worth answering/discussing.

Ah, thanks.

> Note: If a function A with llvm.reloc.none is inlined into other functions, the section referenced by llvm.reloc.none becomes harder for the linker to garbage collect.

Unless I'm misunderstanding, this seems desirable. Presumably code that bears this intrinsic intends to declare that the referenced symbol is needed for something; I would expect such a declaration to be reasonably sticky. For the modular printf itself, these symbols will probably be zero-length bearers of additional relocations to pull in the actual implementation functions. In such cases too, keeping the chain of symbols/sections around makes it more obvious why things are present, a la `--why-extract` and `--why-live`.

> As an intrinsic, this cannot be used with global objects. The !associated metadata can serve as a replacement for ELF in some cases.

Ack; I do like that there are options to generalize this beyond code locations if necessary, but it does seem sensible for there to be more than one spelling too, given the strong-ish split between code and data in LLVM IR. I suppose we could try to make this attribute-only in code too, but that seems... unusual.


https://github.com/llvm/llvm-project/pull/147427


More information about the llvm-commits mailing list