[llvm] [Cygwin] Cygwin cmodel medium for 64 bit (PR #74931)

εΎζŒζ’ Xu Chiheng via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 9 04:46:07 PST 2023


https://github.com/xu-chiheng created https://github.com/llvm/llvm-project/pull/74931

None

>From c1c94308d7c43e3b8d69d59c14abd7be21d9fdc6 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, 9 Dec 2023 20:44:03 +0800
Subject: [PATCH] 1

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

diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 5668b514d6dec0..544b88228d5614 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -206,8 +206,8 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT, bool JIT,
 }
 
 static CodeModel::Model
-getEffectiveX86CodeModel(std::optional<CodeModel::Model> CM, bool JIT,
-                         bool Is64Bit) {
+getEffectiveX86CodeModel(const Triple &TT, std::optional<CodeModel::Model> CM, bool JIT) {
+  bool Is64Bit = TT.getArch() == Triple::x86_64;
   if (CM) {
     if (*CM == CodeModel::Tiny)
       report_fatal_error("Target does not support the tiny CodeModel", false);
@@ -215,6 +215,8 @@ getEffectiveX86CodeModel(std::optional<CodeModel::Model> CM, bool JIT,
   }
   if (JIT)
     return Is64Bit ? CodeModel::Large : CodeModel::Small;
+  if (TT.isWindowsCygwinEnvironment())
+    return Is64Bit ? CodeModel::Medium : CodeModel::Small;
   return CodeModel::Small;
 }
 
@@ -229,7 +231,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
     : LLVMTargetMachine(
           T, computeDataLayout(TT), TT, CPU, FS, Options,
           getEffectiveRelocModel(TT, JIT, RM),
-          getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64),
+          getEffectiveX86CodeModel(TT, CM, JIT),
           OL),
       TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
   // On PS4/PS5, the "return address" of a 'noreturn' call must still be within



More information about the llvm-commits mailing list