[PATCH] D157251: [X86][regcall] Do not produce @ number suffix if it is regcall4

2023-08-09 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157251/new/

https://reviews.llvm.org/D157251

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157251: [X86][regcall] Do not produce @ number suffix if it is regcall4

2023-08-09 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 548479.
yubing added a comment.

small fix


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,43 @@
+// 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(i8 inreg noundef 
signext %a, i8 inreg noundef signext %b)
+// X64: define dso_local x86_regcallcc void @__regcall4__v6(i8 noundef %a, i8 
noundef %b)
+
+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)
+// X64: define dso_local x86_regcallcc void @__regcall4__v7(i64 noundef %a, i8 
noundef %b, i8 noundef %c, i16 noundef %d)
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 @ suffix if it is regcall4
+  if (getASTContext().getLangOpts().RegCall4)
+return;
+
   const FunctionDecl *FD = cast(D);
   const FunctionType *FT = FD->getType()->castAs();
   const FunctionProtoType *Proto = dyn_cast(FT);


Index: clang/test/CodeGen/mangle-windows-regcall4.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-windows-regcall4.c
@@ -0,0 +1,43 @@
+// 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) {}

[PATCH] D157251: [X86][regcall] Do not produce @ number suffix if it is regcall4

2023-08-09 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 548478.
yubing added a comment.

small fix


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,43 @@
+// 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(i8 inreg noundef 
signext %a, i8 inreg noundef signext %b)
+// X64: define dso_local x86_regcallcc void @__regcall4__v6(i8 noundef %a, i8 
noundef %b)
+
+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)
+// X64: define dso_local x86_regcallcc void @__regcall4__v7(i64 noundef %a, i8 
noundef %b, i8 noundef %c, i16 noundef %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 @ suffix if it is regcall4
+  if (getASTContext().getLangOpts().RegCall4)
+return;
+
   const FunctionDecl *FD = cast(D);
   const FunctionType *FT = FD->getType()->castAs();
   const FunctionProtoType *Proto = dyn_cast(FT);


Index: clang/test/CodeGen/mangle-windows-regcall4.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-windows-regcall4.c
@@ -0,0 +1,43 @@
+// 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
+

[PATCH] D157251: [X86][regcall] Do not produce @ number suffix if it is regcall4

2023-08-09 Thread Bing Yu via Phabricator via cfe-commits
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 @ suffix if it is regcall4
+  if (getASTContext().getLangOpts().RegCall4)
+return;
+
   const FunctionDecl *FD = cast(D);
   const FunctionType *FT = FD->getType()->castAs();
   const FunctionProtoType *Proto = dyn_cast(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 

[PATCH] D157251: [X86][regcall] Do not produce @ number suffix if it is regcall4

2023-08-06 Thread Bing Yu via Phabricator via cfe-commits
yubing created this revision.
Herald added a project: All.
yubing requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157251

Files:
  clang/lib/AST/Mangle.cpp


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 @ suffix if it is regcall4
+  if (getASTContext().getLangOpts().RegCall4)
+return;
+
   const FunctionDecl *FD = cast(D);
   const FunctionType *FT = FD->getType()->castAs();
   const FunctionProtoType *Proto = dyn_cast(FT);


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 @ suffix if it is regcall4
+  if (getASTContext().getLangOpts().RegCall4)
+return;
+
   const FunctionDecl *FD = cast(D);
   const FunctionType *FT = FD->getType()->castAs();
   const FunctionProtoType *Proto = dyn_cast(FT);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits