[llvm] [llvm][IR] Add per-global code model attribute (PR #72077)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 11:20:54 PST 2023


aeubanks wrote:

This should definitely have an RFC sent to discourse

The annoying thing is that the x86-64 medium/large code model doesn't necessarily mean that all globals compiled like that are near/far, they mean that globals over a certain size are considered far (the linker places them farther from text to mitigate 32-bit relocation pressure). The way I want to use this feature is to unconditionally mark a global as far regardless of its size, so specifying a specific code model is not quite right for my use case. But maybe for x86-64 we can just say that an explicit "small" code model means the global is unconditionally near and an explicit "large" code model means the global is unconditionally far, even if that's not exactly what the x86-64 code models mean.

Do you need this for functions as well as global variables? For x86-64 theoretically this is useful for both, but in practice we'll probably only use this for global variables.

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


More information about the llvm-commits mailing list