[llvm] f03b100 - [Cygwin] Fix global variable dll import (#121439)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 14:09:02 PST 2025


Author: 王宇逸
Date: 2025-01-03T00:08:58+02:00
New Revision: f03b100e93196ca1ecec20fde3fc48690b3dad7e

URL: https://github.com/llvm/llvm-project/commit/f03b100e93196ca1ecec20fde3fc48690b3dad7e
DIFF: https://github.com/llvm/llvm-project/commit/f03b100e93196ca1ecec20fde3fc48690b3dad7e.diff

LOG: [Cygwin] Fix global variable dll import (#121439)

This PR is necessary for cygwin target of Rust.

References:
*
https://github.com/rust-lang/llvm-project/commit/86657cc39f8e42ae73be810fb0703ddac0eeef94
*
https://github.com/Berrysoft/llvm-project/commit/a807e9f077351d3c6a68f4abe74c94a039759a2e

Added: 
    

Modified: 
    llvm/lib/Target/TargetMachine.cpp
    llvm/test/CodeGen/X86/mingw-refptr.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index c0985f3be91a53..d5365f3c047437 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -204,7 +204,7 @@ bool TargetMachine::shouldAssumeDSOLocal(const GlobalValue *GV) const {
     // don't assume the variables to be DSO local unless we actually know
     // that for sure. This only has to be done for variables; for functions
     // the linker can insert thunks for calling functions from another DLL.
-    if (TT.isWindowsGNUEnvironment() && GV->isDeclarationForLinker() &&
+    if (TT.isOSCygMing() && GV->isDeclarationForLinker() &&
         isa<GlobalVariable>(GV))
       return false;
 

diff  --git a/llvm/test/CodeGen/X86/mingw-refptr.ll b/llvm/test/CodeGen/X86/mingw-refptr.ll
index 73f1a9880913c9..82a90aba386546 100644
--- a/llvm/test/CodeGen/X86/mingw-refptr.ll
+++ b/llvm/test/CodeGen/X86/mingw-refptr.ll
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -mtriple=x86_64-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X64
+; RUN: llc < %s -mtriple=x86_64-pc-cygwin | FileCheck %s -check-prefix=CHECK-X64
 ; RUN: llc < %s -mtriple=i686-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X86
 ; RUN: llc < %s -mtriple=i686-w64-mingw32-none-elf | FileCheck %s -check-prefix=CHECK-X86-ELF
 


        


More information about the llvm-commits mailing list