[clang] [clang][ARM] Accept pcs("aapcs-vfp") on Windows (PR #240569)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 19:52:20 PST 2026


https://github.com/hamed7ir updated https://github.com/llvm/llvm-project/pull/240569

>From b71a2d5b6853564f283ec12d08ebd66b28199b69 Mon Sep 17 00:00:00 2001
From: hamed7ir <hamedghorbani17 at live.com>
Date: Mon, 9 Nov 2026 11:35:19 -0800
Subject: [PATCH 1/2] [clang][ARM] Accept pcs("aapcs-vfp") on Windows

Windows on ARM always uses AAPCS-VFP, but pcs("aapcs-vfp") gave a warning
there that the calling convention is not supported, which is an error with
-Werror. Skia uses the attribute. Ignore it on Windows, like the x86
conventions, so it means the default convention, which it is.

Assisted-by: Claude Opus 5.5 (Anthropic)
---
 clang/lib/Basic/Targets/ARM.cpp           |  3 +++
 clang/test/CodeGenCXX/arm-windows-pcs.cpp | 13 +++++++++++++
 clang/test/Sema/arm-windows-pcs.c         | 17 +++++++++++++++++
 3 files changed, 33 insertions(+)
 create mode 100644 clang/test/CodeGenCXX/arm-windows-pcs.cpp
 create mode 100644 clang/test/Sema/arm-windows-pcs.c

diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index b1f85587ca271c..e64b4d5e118d25 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1464,6 +1464,9 @@ WindowsARMTargetInfo::checkCallingConvention(CallingConv CC) const {
   case CC_X86FastCall:
   case CC_X86VectorCall:
     return CCCR_Ignore;
+  // AAPCS-VFP is the default convention on Windows on ARM.
+  case CC_AAPCS_VFP:
+    return CCCR_Ignore;
   case CC_C:
   case CC_DeviceKernel:
   case CC_PreserveMost:
diff --git a/clang/test/CodeGenCXX/arm-windows-pcs.cpp b/clang/test/CodeGenCXX/arm-windows-pcs.cpp
new file mode 100644
index 00000000000000..81326324e7af0d
--- /dev/null
+++ b/clang/test/CodeGenCXX/arm-windows-pcs.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple thumbv7-windows-msvc -fms-extensions -Werror -emit-llvm -o - %s | FileCheck %s
+
+// pcs("aapcs-vfp") is the default on Windows on ARM: no warning, and the
+// functions mangle as __cdecl.
+
+#define ABI __attribute__((pcs("aapcs-vfp")))
+using StageFn = void ABI (*)(float *, float);
+static void ABI stage(float *p, float v) { *p = v; }
+StageFn get() { return stage; }
+void (*plain)(float *, float) = get();
+
+// CHECK-DAG: define dso_local arm_aapcs_vfpcc {{.*}}ptr @"?get@@YAP6AXPAMM at ZXZ"()
+// CHECK-DAG: define internal arm_aapcs_vfpcc void @"?stage@@YAXPAMM at Z"(
diff --git a/clang/test/Sema/arm-windows-pcs.c b/clang/test/Sema/arm-windows-pcs.c
new file mode 100644
index 00000000000000..e02849397024e1
--- /dev/null
+++ b/clang/test/Sema/arm-windows-pcs.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7-w64-windows-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7-windows -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+// pcs("aapcs-vfp") is the default on Windows on ARM, so it is accepted
+// silently. pcs("aapcs") would change the ABI and is still diagnosed.
+
+float __attribute__((pcs("aapcs-vfp"))) with_pcs(float a, float b) { return a + b; }
+float without_pcs(float a, float b) { return a + b; }
+
+// The attributed function and a plain function have the same type.
+float (*fp)(float, float) = with_pcs;
+
+float __attribute__((pcs("aapcs"))) base_aapcs(float a, float b) { return a + b; } // expected-warning {{'pcs' calling convention is not supported for this target}}
+
+// CHECK: define dso_local arm_aapcs_vfpcc float @with_pcs(
+// CHECK: define dso_local arm_aapcs_vfpcc float @without_pcs(

>From 99ab9647da9281c9db899e2e7efea4d1815bf8ad Mon Sep 17 00:00:00 2001
From: hamed7ir <hamedghorbani17 at live.com>
Date: Mon, 9 Nov 2026 18:39:29 -0800
Subject: [PATCH 2/2] Fold the case into the x86 group and keep one test

Assisted-by: Claude Opus 5.5 (Anthropic)
---
 clang/lib/Basic/Targets/ARM.cpp           |  2 --
 clang/test/CodeGenCXX/arm-windows-pcs.cpp | 13 -------------
 clang/test/Sema/arm-windows-pcs.c         |  8 +-------
 3 files changed, 1 insertion(+), 22 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/arm-windows-pcs.cpp

diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index e64b4d5e118d25..7c1fa9f3f3af05 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1463,8 +1463,6 @@ WindowsARMTargetInfo::checkCallingConvention(CallingConv CC) const {
   case CC_X86ThisCall:
   case CC_X86FastCall:
   case CC_X86VectorCall:
-    return CCCR_Ignore;
-  // AAPCS-VFP is the default convention on Windows on ARM.
   case CC_AAPCS_VFP:
     return CCCR_Ignore;
   case CC_C:
diff --git a/clang/test/CodeGenCXX/arm-windows-pcs.cpp b/clang/test/CodeGenCXX/arm-windows-pcs.cpp
deleted file mode 100644
index 81326324e7af0d..00000000000000
--- a/clang/test/CodeGenCXX/arm-windows-pcs.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -triple thumbv7-windows-msvc -fms-extensions -Werror -emit-llvm -o - %s | FileCheck %s
-
-// pcs("aapcs-vfp") is the default on Windows on ARM: no warning, and the
-// functions mangle as __cdecl.
-
-#define ABI __attribute__((pcs("aapcs-vfp")))
-using StageFn = void ABI (*)(float *, float);
-static void ABI stage(float *p, float v) { *p = v; }
-StageFn get() { return stage; }
-void (*plain)(float *, float) = get();
-
-// CHECK-DAG: define dso_local arm_aapcs_vfpcc {{.*}}ptr @"?get@@YAP6AXPAMM at ZXZ"()
-// CHECK-DAG: define internal arm_aapcs_vfpcc void @"?stage@@YAXPAMM at Z"(
diff --git a/clang/test/Sema/arm-windows-pcs.c b/clang/test/Sema/arm-windows-pcs.c
index e02849397024e1..fe69ea75722017 100644
--- a/clang/test/Sema/arm-windows-pcs.c
+++ b/clang/test/Sema/arm-windows-pcs.c
@@ -1,17 +1,11 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple thumbv7-w64-windows-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple thumbv7-windows -emit-llvm -o - %s 2>&1 | FileCheck %s
 
 // pcs("aapcs-vfp") is the default on Windows on ARM, so it is accepted
 // silently. pcs("aapcs") would change the ABI and is still diagnosed.
 
 float __attribute__((pcs("aapcs-vfp"))) with_pcs(float a, float b) { return a + b; }
-float without_pcs(float a, float b) { return a + b; }
 
-// The attributed function and a plain function have the same type.
+// The attributed function has the plain function type.
 float (*fp)(float, float) = with_pcs;
 
 float __attribute__((pcs("aapcs"))) base_aapcs(float a, float b) { return a + b; } // expected-warning {{'pcs' calling convention is not supported for this target}}
-
-// CHECK: define dso_local arm_aapcs_vfpcc float @with_pcs(
-// CHECK: define dso_local arm_aapcs_vfpcc float @without_pcs(



More information about the cfe-commits mailing list