[llvm] [X86] Don't use rip-relative lea to get a function address in medium static mode (PR #75656)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 13:18:21 PST 2023
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/75656
This essentially reverts https://reviews.llvm.org/D140593. Somewhere
along the line we properly fixed the medium code model to assume
functions are small.
>From 3b3b9e784f410c1b276f5f73d4ab2242b6530c9c Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Fri, 15 Dec 2023 13:16:12 -0800
Subject: [PATCH] [X86] Don't use rip-relative lea to get a function address in
medium static mode
This essentially reverts https://reviews.llvm.org/D140593. Somewhere
along the line we properly fixed the medium code model to assume
functions are small.
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 7 -------
llvm/test/CodeGen/X86/code-model-elf.ll | 4 ++--
2 files changed, 2 insertions(+), 9 deletions(-)
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:
More information about the llvm-commits
mailing list