[llvm] [X86] Don't use rip-relative lea to get a function address in medium static mode (PR #75656)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 13:18:48 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
This essentially reverts https://reviews.llvm.org/D140593. Somewhere
along the line we properly fixed the medium code model to assume
functions are small.
---
Full diff: https://github.com/llvm/llvm-project/pull/75656.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (-7)
- (modified) llvm/test/CodeGen/X86/code-model-elf.ll (+2-2)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index cb117475dbe4cf..99c492087a4585 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18329,13 +18329,6 @@ unsigned X86TargetLowering::getGlobalWrapperKind(
OpFlags == X86II::MO_DLLIMPORT))
return X86ISD::WrapperRIP;
- // In the medium model, functions can always be referenced RIP-relatively,
- // since they must be within 2GiB. This is also possible in non-PIC mode, and
- // shorter than the 64-bit absolute immediate that would otherwise be emitted.
- if (getTargetMachine().getCodeModel() == CodeModel::Medium &&
- isa_and_nonnull<Function>(GV))
- return X86ISD::WrapperRIP;
-
// GOTPCREL references must always use RIP.
if (OpFlags == X86II::MO_GOTPCREL || OpFlags == X86II::MO_GOTPCREL_NORELAX)
return X86ISD::WrapperRIP;
diff --git a/llvm/test/CodeGen/X86/code-model-elf.ll b/llvm/test/CodeGen/X86/code-model-elf.ll
index be93f6530ae4c4..6112f2a57b82c3 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -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
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: lea_static_fn:
@@ -882,7 +882,7 @@ define dso_local ptr @lea_global_fn() #0 {
;
; MEDIUM-STATIC-LABEL: lea_global_fn:
; MEDIUM-STATIC: # %bb.0:
-; MEDIUM-STATIC-NEXT: leaq global_fn(%rip), %rax
+; MEDIUM-STATIC-NEXT: movl $global_fn, %eax
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: lea_global_fn:
``````````
</details>
https://github.com/llvm/llvm-project/pull/75656
More information about the llvm-commits
mailing list