[llvm] 5023684 - [AArch64][SME] Emit unimplemented error for non-lazy-save of ZA. (#227608)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 06:14:50 PDT 2026


Author: Sander de Smalen
Date: 2026-09-30T14:14:42+01:00
New Revision: 5023684dff225519cbb714370a94a675487d5a28

URL: https://github.com/llvm/llvm-project/commit/5023684dff225519cbb714370a94a675487d5a28
DIFF: https://github.com/llvm/llvm-project/commit/5023684dff225519cbb714370a94a675487d5a28.diff

LOG: [AArch64][SME] Emit unimplemented error for non-lazy-save of ZA. (#227608)

A non-lazy-save of ZA is required when the caller has both ZA and ZT0
state and calls a function with a shared-ZA interface that only shares
ZT0.

This case is already rejected by Clang but LLVM compiles it without
generating a save of ZA.

Added: 
    llvm/test/CodeGen/AArch64/sme-non-lazy-save-za.ll

Modified: 
    llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    llvm/lib/Target/AArch64/AArch64SMEAttributes.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 2ddc7fe934430..9885dfc854d11 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10603,6 +10603,9 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
   // Determine whether we need any streaming mode changes.
   SMECallAttrs CallAttrs =
       getSMECallAttrs(MF.getFunction(), getRuntimeLibcallsInfo(), CLI);
+  if (CallAttrs.requiresNonLazySaveZA())
+    reportFatalUsageError(
+        "Calls that require saving ZA non-lazily is not yet implemented");
 
   std::optional<unsigned> ZAMarkerNode = getZAMarkerForCall(CallAttrs);
 

diff  --git a/llvm/lib/Target/AArch64/AArch64SMEAttributes.h b/llvm/lib/Target/AArch64/AArch64SMEAttributes.h
index a340866335793..5a1e3d60df70a 100644
--- a/llvm/lib/Target/AArch64/AArch64SMEAttributes.h
+++ b/llvm/lib/Target/AArch64/AArch64SMEAttributes.h
@@ -189,6 +189,11 @@ class SMECallAttrs {
            !callee().isSMEABIRoutine();
   }
 
+  bool requiresNonLazySaveZA() const {
+    return caller().hasZAState() && callee().hasSharedZAInterface() &&
+           !callee().sharesZA();
+  }
+
   bool requiresPreservingZT0() const {
     return caller().hasZT0State() && !callee().sharesZT0() &&
            !callee().hasAgnosticZAInterface();
@@ -200,7 +205,8 @@ class SMECallAttrs {
   }
 
   bool requiresZASave() const {
-    return requiresLazySave() || requiresPreservingAllZAState();
+    return requiresLazySave() || requiresNonLazySaveZA() ||
+           requiresPreservingAllZAState();
   }
 };
 

diff  --git a/llvm/test/CodeGen/AArch64/sme-non-lazy-save-za.ll b/llvm/test/CodeGen/AArch64/sme-non-lazy-save-za.ll
new file mode 100644
index 0000000000000..7a8827dfedd66
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sme-non-lazy-save-za.ll
@@ -0,0 +1,14 @@
+; RUN: not llc < %s 2>&1 | FileCheck %s
+; RUN: not llc -fast-isel=true < %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=true -global-isel-abort=2 < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: Calls that require saving ZA non-lazily is not yet implemented
+
+target triple = "aarch64"
+
+define void @foo(ptr %f) #0 {
+  call void %f() "aarch64_inout_zt0"
+  ret void
+}
+
+attributes #0 = { "aarch64_inout_zt0" "aarch64_inout_za" "target-feature"="+sme,+sve" }


        


More information about the llvm-commits mailing list