[llvm] [X86] Don't use rip-relative lea to get a function address in medium static mode (PR #75656)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 14:28:22 PST 2023


================
@@ -829,7 +829,7 @@ define dso_local ptr @lea_static_fn() #0 {
 ;
 ; MEDIUM-STATIC-LABEL: lea_static_fn:
 ; MEDIUM-STATIC:       # %bb.0:
-; MEDIUM-STATIC-NEXT:    leaq static_fn(%rip), %rax
+; MEDIUM-STATIC-NEXT:    movl $static_fn, %eax
----------------
rnk wrote:

I kind of wished we used LEA here, but this is at least consistent with the small static code model.

There's a more interesting inconsistency between the small and medium model access for a small global here:
https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/X86/code-model-elf.ll#L388

If we use the RIP wrapper, we can fold the load displacement and the RIP memory operand together into the load.

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


More information about the llvm-commits mailing list