[llvm-branch-commits] [clang] [clang][Driver] Use the Windows ARM64 defaults for aarch64-unknown-uefi (PR #232706)

Prabhu Rajasekaran via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 16 04:57:22 PDT 2026


https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/232706

Match the Windows ARM64 driver defaults for aarch64-unknown-uefi, which
follows the same ABI:

* char is signed, so do not pass -fno-signed-char,
* the frame chain must stay valid even when frame pointers are omitted,
  so -fomit-frame-pointer yields -mframe-pointer=reserved rather than
  none, as the backend reserves the frame pointer for UEFI as well.

Assisted-by: Claude

---

<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

>From 0ea92e04e123918b4891b312f5abf94156ccd39e Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Oct 2026 04:51:56 -0700
Subject: [PATCH] [clang][Driver] Use the Windows ARM64 defaults for
 aarch64-unknown-uefi

Match the Windows ARM64 driver defaults for aarch64-unknown-uefi, which
follows the same ABI:

* char is signed, so do not pass -fno-signed-char,
* the frame chain must stay valid even when frame pointers are omitted,
  so -fomit-frame-pointer yields -mframe-pointer=reserved rather than
  none, as the backend reserves the frame pointer for UEFI as well.

Assisted-by: Claude
---
 clang/lib/Driver/ToolChains/Clang.cpp             | 2 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp        | 8 ++++----
 clang/test/Driver/aarch64-uefi-constructed-args.c | 9 +++++++++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 26218d85e05e35..bbcafb99a69249 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1215,7 +1215,7 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
-    if (Triple.isOSDarwin() || Triple.isOSWindows())
+    if (Triple.isOSDarwin() || Triple.isOSWindowsOrUEFI())
       return true;
     return false;
 
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 7c832ef405fa51..7d77cd0b916324 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -211,10 +211,10 @@ static bool mustMaintainValidFrameChain(const llvm::opt::ArgList &Args,
     return false;
 
   case llvm::Triple::aarch64:
-    // Arm64 Windows requires that the frame chain is valid, as there is no
-    // way to indicate during a stack walk that a frame has used the frame
-    // pointer as a general purpose register.
-    return Triple.isOSWindows();
+    // Arm64 Windows (and UEFI, which follows the same ABI) requires that the
+    // frame chain is valid, as there is no way to indicate during a stack walk
+    // that a frame has used the frame pointer as a general purpose register.
+    return Triple.isOSWindowsOrUEFI();
   }
 }
 
diff --git a/clang/test/Driver/aarch64-uefi-constructed-args.c b/clang/test/Driver/aarch64-uefi-constructed-args.c
index 704bdf6a79db3c..ac84b06856f42b 100644
--- a/clang/test/Driver/aarch64-uefi-constructed-args.c
+++ b/clang/test/Driver/aarch64-uefi-constructed-args.c
@@ -5,6 +5,7 @@
 // CHECK: "-cc1"
 // CHECK-SAME: "-triple" "aarch64-unknown-uefi"
 // CHECK-SAME: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-SAME: "-mframe-pointer=non-leaf"
 // CHECK-SAME: "-fms-extensions"
 // CHECK-NEXT: "/nologo"
 // CHECK-SAME: "/subsystem:efi_application"
@@ -13,6 +14,14 @@
 // CHECK-SAME: "/debug"
 // CHECK-SAME: "/Brepro"
 
+// As on Windows ARM64, the frame chain must stay valid even when frame
+// pointers are omitted, and char is signed.
+// RUN: %clang -### --target=aarch64-unknown-uefi -fomit-frame-pointer -c -- %s 2>&1 \
+// RUN:     | FileCheck -check-prefixes=DEFAULTS %s
+// DEFAULTS: "-cc1"
+// DEFAULTS-SAME: "-mframe-pointer=reserved"
+// DEFAULTS-NOT: "-fno-signed-char"
+
 // RUN: %clang -### --target=aarch64-unknown-uefi -print-search-dirs 2>&1 \
 // RUN:     | FileCheck -check-prefixes=PROGPATH %s
 // PROGPATH: InstalledDir: [[DRIVER_INSTALLED_DIR:.*]]



More information about the llvm-branch-commits mailing list