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

εΎζŒζ’ Xu Chiheng via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 31 23:02:50 PST 2023


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

>From 459841003a97a03d5fcc869b559d94596d545a0c 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: Mon, 1 Jan 2024 15:02:14 +0800
Subject: [PATCH] 1

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

diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 5668b514d6dec0..fcfd4bdba96783 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -206,8 +206,9 @@ 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 +216,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;
 }
 
@@ -226,11 +229,9 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
                                    std::optional<Reloc::Model> RM,
                                    std::optional<CodeModel::Model> CM,
                                    CodeGenOptLevel OL, bool JIT)
-    : LLVMTargetMachine(
-          T, computeDataLayout(TT), TT, CPU, FS, Options,
-          getEffectiveRelocModel(TT, JIT, RM),
-          getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64),
-          OL),
+    : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
+                        getEffectiveRelocModel(TT, JIT, RM),
+                        getEffectiveX86CodeModel(TT, CM, JIT), OL),
       TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
   // On PS4/PS5, the "return address" of a 'noreturn' call must still be within
   // the calling function, and TrapUnreachable is an easy way to get that.



More information about the llvm-commits mailing list