Skip to content

Conversation

@kikairoya
Copy link
Contributor

Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC.

Divided from #138773

Behaves as same as both of Clang and GCC targetting MinGW.
Required for compatibility for Cygwin-GCC.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. labels May 13, 2025
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)

Changes

Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC.

Divided from #138773


Full diff: https://github.com/llvm/llvm-project/pull/139798.diff

8 Files Affected:

  • (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+2-5)
  • (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1)
  • (modified) clang/test/CodeGenCXX/dllexport-missing-key.cpp (+1)
  • (modified) clang/test/CodeGenCXX/dllimport-missing-key.cpp (+1)
  • (modified) clang/test/CodeGenCXX/dllimport-rtti.cpp (+5-2)
  • (modified) clang/test/CodeGenCXX/rtti-mingw64.cpp (+2)
  • (modified) clang/test/CodeGenCXX/virt-dtor-key.cpp (+6-2)
  • (modified) clang/test/CodeGenCXX/vtable-key-function-ios.cpp (+2)
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 70b53be7e77a3..8826085c596da 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3754,7 +3754,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
     bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
 
     // Don't import the RTTI but emit it locally.
-    if (CGM.getTriple().isWindowsGNUEnvironment())
+    if (CGM.getTriple().isOSCygMing())
       return false;
 
     if (CGM.getVTables().isVTableExternal(RD)) {
@@ -4041,10 +4041,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
           return llvm::GlobalValue::ExternalLinkage;
       // MinGW always uses LinkOnceODRLinkage for type info.
       if (RD->isDynamicClass() &&
-          !CGM.getContext()
-               .getTargetInfo()
-               .getTriple()
-               .isWindowsGNUEnvironment())
+          !CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
         return CGM.getVTableLinkage(RD);
     }
 
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbccb567e2adf..aee77c5ada0ba 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6274,7 +6274,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
     }
   } MarkingDllexportedContext(S, Class, ClassAttr->getLocation());
 
-  if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+  if (S.Context.getTargetInfo().getTriple().isOSCygMing())
     S.MarkVTableUsed(Class->getLocation(), Class, true);
 
   for (Decl *Member : Class->decls()) {
diff --git a/clang/test/CodeGenCXX/dllexport-missing-key.cpp b/clang/test/CodeGenCXX/dllexport-missing-key.cpp
index 90e736f6fad3a..505679f315331 100644
--- a/clang/test/CodeGenCXX/dllexport-missing-key.cpp
+++ b/clang/test/CodeGenCXX/dllexport-missing-key.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
 
 class __declspec(dllexport) QAbstractLayoutStyleInfo {
 public:
diff --git a/clang/test/CodeGenCXX/dllimport-missing-key.cpp b/clang/test/CodeGenCXX/dllimport-missing-key.cpp
index d8ef7aa7ea680..9eb9e7b5bbb0d 100644
--- a/clang/test/CodeGenCXX/dllimport-missing-key.cpp
+++ b/clang/test/CodeGenCXX/dllimport-missing-key.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin   -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
 
 class __declspec(dllimport) QObjectData {
 public:
diff --git a/clang/test/CodeGenCXX/dllimport-rtti.cpp b/clang/test/CodeGenCXX/dllimport-rtti.cpp
index f23a242c4bedc..046bf5020398d 100644
--- a/clang/test/CodeGenCXX/dllimport-rtti.cpp
+++ b/clang/test/CodeGenCXX/dllimport-rtti.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
-// RUN: %clang_cc1 -triple i686-windows-gnu  -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -triple i686-windows-msvc  -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -triple i686-windows-gnu   -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -triple i686-pc-cygwin     -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
 
 struct __declspec(dllimport) S {
   virtual void f() {}
diff --git a/clang/test/CodeGenCXX/rtti-mingw64.cpp b/clang/test/CodeGenCXX/rtti-mingw64.cpp
index e0a4607cf28c3..9de280602945d 100644
--- a/clang/test/CodeGenCXX/rtti-mingw64.cpp
+++ b/clang/test/CodeGenCXX/rtti-mingw64.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-windows-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   %s -emit-llvm -o - | FileCheck %s
+
 struct A { int a; };
 struct B : virtual A { int b; };
 B b;
diff --git a/clang/test/CodeGenCXX/virt-dtor-key.cpp b/clang/test/CodeGenCXX/virt-dtor-key.cpp
index d3b9ab3351518..cd169ab01dc8b 100644
--- a/clang/test/CodeGenCXX/virt-dtor-key.cpp
+++ b/clang/test/CodeGenCXX/virt-dtor-key.cpp
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -triple i386-linux -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple i386-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
+// RUN: %clang_cc1 -triple i686-linux         -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-gnu   -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
+// RUN: %clang_cc1 -triple i686-pc-cygwin     -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
+
 // CHECK: @_ZTI3foo ={{.*}} constant
 // CHECK-MINGW: @_ZTI3foo = linkonce_odr
 class foo {
diff --git a/clang/test/CodeGenCXX/vtable-key-function-ios.cpp b/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
index 43abfb62c73a6..b11d0a62a04a6 100644
--- a/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
+++ b/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -3,6 +3,8 @@
 
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin      -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin      -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
 // The 'b' variants ask for the vtable second.

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mstorsjo mstorsjo merged commit a3d52ea into llvm:main May 14, 2025
15 checks passed
jeremyd2019 pushed a commit to jeremyd2019/llvm-project that referenced this pull request May 14, 2025
Behaves as same as both of Clang and GCC targetting MinGW. Required for
compatibility for Cygwin-GCC.

Divided from llvm#138773
jeremyd2019 pushed a commit to jeremyd2019/llvm-project that referenced this pull request May 15, 2025
Behaves as same as both of Clang and GCC targetting MinGW. Required for
compatibility for Cygwin-GCC.

Divided from llvm#138773
@kikairoya kikairoya deleted the cygwin-export-rtti branch May 24, 2025 08:18
jeremyd2019 pushed a commit to jeremyd2019/llvm-project that referenced this pull request Aug 9, 2025
Behaves as same as both of Clang and GCC targetting MinGW. Required for
compatibility for Cygwin-GCC.

Divided from llvm#138773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants