[llvm] [Cygwin] Cygwin X86ISelDAGToDAG.cpp (PR #76284)

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


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

Fix the regression caused by commit ec92d74a0ef89b9dd46aee6ec8aca6bfd3c66a54 2023-12-14, that, in Cygwin, Clang can't build binutils 2.42.
configure:4686: checking whether we are cross compiling
configure:4694: clang -o conftest.exe -march=x86-64 -O3  -Wl,--strip-all conftest.c  >&5
/cygdrive/c/Users/ADMINI~1/AppData/Local/Temp/conftest-385c4a.o:conftest.c:(.text+0x10): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
/cygdrive/c/Users/ADMINI~1/AppData/Local/Temp/conftest-385c4a.o:conftest.c:(.text+0x15): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4698: $? = 1
configure:4705: ./conftest.exe
../binutils/configure: line 4707: ./conftest.exe: No such file or directory
configure:4709: $? = 127
configure:4716: error: in `/cygdrive/e/Note/Tool/binutils-release-build':
configure:4718: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details


>From 49fc987ace999feed195cb5dcb3dc30891649f9b 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:15:59 +0800
Subject: [PATCH] 1

---
 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 7ec59c74f5f58c..c93ae875b3e4bb 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2947,18 +2947,15 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
     return false;
 
   Imm = N;
-  // Small/medium code model can reference non-TargetGlobalAddress objects with
-  // 32 bit constants.
-  if (N->getOpcode() != ISD::TargetGlobalAddress) {
-    return TM.getCodeModel() == CodeModel::Small ||
-           TM.getCodeModel() == CodeModel::Medium;
-  }
+  if (N->getOpcode() != ISD::TargetGlobalAddress)
+    return TM.getCodeModel() == CodeModel::Small;
 
-  const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
-  if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
-    return CR->getUnsignedMax().ult(1ull << 32);
+  std::optional<ConstantRange> CR =
+      cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
+  if (!CR)
+    return TM.getCodeModel() == CodeModel::Small;
 
-  return !TM.isLargeGlobalValue(GV);
+  return CR->getUnsignedMax().ult(1ull << 32);
 }
 
 bool X86DAGToDAGISel::selectLEA64_32Addr(SDValue N, SDValue &Base,



More information about the llvm-commits mailing list