yubing updated this revision to Diff 548477. yubing added a comment. Herald added a subscriber: mstorsjo.
add testcase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157251/new/ https://reviews.llvm.org/D157251 Files: clang/lib/AST/Mangle.cpp clang/test/CodeGen/mangle-windows-regcall4.c Index: clang/test/CodeGen/mangle-windows-regcall4.c =================================================================== --- /dev/null +++ clang/test/CodeGen/mangle-windows-regcall4.c @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -regcall4 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 -regcall4 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-windows-msvc-elf -regcall4 | FileCheck %s --check-prefix=ELF32 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 -regcall4 | FileCheck %s --check-prefix=X64 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 -regcall4 | FileCheck %s --check-prefix=X64 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc-elf -regcall4 | FileCheck %s --check-prefix=ELF64 + +// CHECK: target datalayout = "e-m:x-{{.*}}" +// X64: target datalayout = "e-m:w-{{.*}}" +// ELF32: target datalayout = "e-m:e-{{.*}}" +// ELF64: target datalayout = "e-m:e-{{.*}}" + +void __regcall v1(void) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v1 +// X64: define dso_local x86_regcallcc void @__regcall4__v1 +// ELF32: define{{.*}} x86_regcallcc void @__regcall4__v1 +// ELF64: define{{.*}} x86_regcallcc void @__regcall4__v1 + +void __regcall v2(char a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v2 +// X64: define dso_local x86_regcallcc void @__regcall4__v2 +// ELF32: define{{.*}} x86_regcallcc void @__regcall4__v2 +// ELF64: define{{.*}} x86_regcallcc void @__regcall4__v2 + +void __regcall v3(short a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v3 +// X64: define dso_local x86_regcallcc void @__regcall4__v3 + +void __regcall v4(int a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v4 +// X64: define dso_local x86_regcallcc void @__regcall4__v4 + +void __regcall v5(long long a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v5 +// X64: define dso_local x86_regcallcc void @__regcall4__v5 + +void __regcall v6(char a, char b) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v6 +// X64: define dso_local x86_regcallcc void @__regcall4__v6 + +void __regcall v7(long long a, char b, char c, short d) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v7(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 inreg noundef signext %d) \ No newline at end of file Index: clang/lib/AST/Mangle.cpp =================================================================== --- clang/lib/AST/Mangle.cpp +++ clang/lib/AST/Mangle.cpp @@ -212,6 +212,10 @@ else mangleCXXName(GD, Out); + // do no produce @<number> suffix if it is regcall4 + if (getASTContext().getLangOpts().RegCall4) + return; + const FunctionDecl *FD = cast<FunctionDecl>(D); const FunctionType *FT = FD->getType()->castAs<FunctionType>(); const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT);
Index: clang/test/CodeGen/mangle-windows-regcall4.c =================================================================== --- /dev/null +++ clang/test/CodeGen/mangle-windows-regcall4.c @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -regcall4 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 -regcall4 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-windows-msvc-elf -regcall4 | FileCheck %s --check-prefix=ELF32 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 -regcall4 | FileCheck %s --check-prefix=X64 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 -regcall4 | FileCheck %s --check-prefix=X64 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc-elf -regcall4 | FileCheck %s --check-prefix=ELF64 + +// CHECK: target datalayout = "e-m:x-{{.*}}" +// X64: target datalayout = "e-m:w-{{.*}}" +// ELF32: target datalayout = "e-m:e-{{.*}}" +// ELF64: target datalayout = "e-m:e-{{.*}}" + +void __regcall v1(void) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v1 +// X64: define dso_local x86_regcallcc void @__regcall4__v1 +// ELF32: define{{.*}} x86_regcallcc void @__regcall4__v1 +// ELF64: define{{.*}} x86_regcallcc void @__regcall4__v1 + +void __regcall v2(char a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v2 +// X64: define dso_local x86_regcallcc void @__regcall4__v2 +// ELF32: define{{.*}} x86_regcallcc void @__regcall4__v2 +// ELF64: define{{.*}} x86_regcallcc void @__regcall4__v2 + +void __regcall v3(short a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v3 +// X64: define dso_local x86_regcallcc void @__regcall4__v3 + +void __regcall v4(int a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v4 +// X64: define dso_local x86_regcallcc void @__regcall4__v4 + +void __regcall v5(long long a) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v5 +// X64: define dso_local x86_regcallcc void @__regcall4__v5 + +void __regcall v6(char a, char b) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v6 +// X64: define dso_local x86_regcallcc void @__regcall4__v6 + +void __regcall v7(long long a, char b, char c, short d) {} +// CHECK: define dso_local x86_regcallcc void @__regcall4__v7(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 inreg noundef signext %d) \ No newline at end of file Index: clang/lib/AST/Mangle.cpp =================================================================== --- clang/lib/AST/Mangle.cpp +++ clang/lib/AST/Mangle.cpp @@ -212,6 +212,10 @@ else mangleCXXName(GD, Out); + // do no produce @<number> suffix if it is regcall4 + if (getASTContext().getLangOpts().RegCall4) + return; + const FunctionDecl *FD = cast<FunctionDecl>(D); const FunctionType *FT = FD->getType()->castAs<FunctionType>(); const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits