[llvm] [Cygwin] Cygwin X86ISelLowering.cpp (PR #74978)

εΎζŒζ’ Xu Chiheng via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 23 03:28:00 PST 2023


https://github.com/xu-chiheng updated https://github.com/llvm/llvm-project/pull/74978

>From 4813999130a6e8e18a1899b438a40be0aa6a60c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 <chiheng.xu at gmail.com>
Date: Sat, 23 Dec 2023 19:26:46 +0800
Subject: [PATCH] 1

---
 llvm/lib/Target/X86/X86ISelLowering.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index d69976342fcbd0..270bd022371359 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18298,10 +18298,15 @@ unsigned X86TargetLowering::getGlobalWrapperKind(
   if (GV && GV->isAbsoluteSymbolRef())
     return X86ISD::Wrapper;
 
-  // The following OpFlags under RIP-rel PIC use RIP.
+  CodeModel::Model M = getTargetMachine().getCodeModel();
   if (Subtarget.isPICStyleRIPRel() &&
-      (OpFlags == X86II::MO_NO_FLAG || OpFlags == X86II::MO_COFFSTUB ||
-       OpFlags == X86II::MO_DLLIMPORT))
+      (M == CodeModel::Small || M == CodeModel::Kernel))
+    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 (M == CodeModel::Medium && isa_and_nonnull<Function>(GV))
     return X86ISD::WrapperRIP;
 
   // In the medium model, functions can always be referenced RIP-relatively,



More information about the llvm-commits mailing list