Skip to content

Commit 9aa1205

Browse files
kikairoyajeremyd2019
authored andcommitted
[Clang][Cygwin] Use correct mangling rule (llvm#158404)
In llvm@45ca613, whether to mangle names based on calling conventions according to Microsoft conventions was refactored to a bool in the TargetInfo. Cygwin targets also require this mangling, but were missed, presumably due to lack of test coverage of these targets. This commit enables the name mangling for Cygwin, and also enables test coverage of this mangling on Cygwin targets. (cherry picked from commit 4abcbb0)
1 parent 03731bf commit 9aa1205

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

clang/lib/Basic/Targets/X86.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
649649
: X86_32TargetInfo(Triple, Opts) {
650650
this->WCharType = TargetInfo::UnsignedShort;
651651
this->WIntType = TargetInfo::UnsignedInt;
652+
this->UseMicrosoftManglingForC = true;
652653
DoubleAlign = LongLongAlign = 64;
653654
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-"
654655
"i128:128-f80:32-n8:16:32-a:0:32-S32",
@@ -986,6 +987,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
986987
: X86_64TargetInfo(Triple, Opts) {
987988
this->WCharType = TargetInfo::UnsignedShort;
988989
this->WIntType = TargetInfo::UnsignedInt;
990+
this->UseMicrosoftManglingForC = true;
989991
}
990992

991993
void getTargetDefines(const LangOptions &Opts,

clang/test/CodeGen/mangle-windows.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
2-
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | FileCheck %s
2+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | FileCheck %s
3+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-cygwin | FileCheck %s
34
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-windows-msvc-elf | FileCheck %s --check-prefix=ELF32
45
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=X64
5-
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 | FileCheck %s --check-prefix=X64
6+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 | FileCheck %s --check-prefix=X64
7+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-cygwin | FileCheck %s --check-prefix=X64
68
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc-elf | FileCheck %s --check-prefix=ELF64
79

810
// CHECK: target datalayout = "e-m:x-{{.*}}"

clang/test/CodeGenCXX/mangle-windows.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | \
55
// RUN: FileCheck --check-prefix=ITANIUM %s
66

7+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-cygwin | \
8+
// RUN: FileCheck --check-prefix=ITANIUM %s
9+
710
void __stdcall f1(void) {}
811
// WIN: define dso_local x86_stdcallcc void @"?f1@@YGXXZ"
912
// ITANIUM: define dso_local x86_stdcallcc void @"\01__Z2f1v@0"

0 commit comments

Comments
 (0)