[llvm] [AArch64][SME] Remove unused ZA lazy-save (PR #81648)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 05:41:01 PDT 2024


================
@@ -7311,10 +7351,28 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
   if (Subtarget->hasCustomCallingConv())
     Subtarget->getRegisterInfo()->UpdateCustomCalleeSavedRegs(MF);
 
-  // Conservatively assume the function requires the lazy-save mechanism.
+  // Create a 16 Byte TPIDR2 object. The dynamic buffer
+  // will be expanded and stored in the static object later using a pseudonode.
   if (SMEAttrs(MF.getFunction()).hasZAState()) {
-    unsigned TPIDR2Obj = allocateLazySaveBuffer(Chain, DL, DAG);
-    FuncInfo->setLazySaveTPIDR2Obj(TPIDR2Obj);
+    TPIDR2Object &TPIDR2 = FuncInfo->getTPIDR2Obj();
+    TPIDR2.FrameIndex = MFI.CreateStackObject(16, Align(16), false);
+    SDValue SVL = DAG.getNode(AArch64ISD::RDSVL, DL, MVT::i64,
+                              DAG.getConstant(1, DL, MVT::i32));
+    SDValue Size = DAG.getNode(ISD::MUL, DL, MVT::i64, SVL, SVL);
+
+    SDValue Buffer;
+    if (!Subtarget->isTargetWindows() && !hasInlineStackProbe(MF)) {
+      Buffer = DAG.getNode(AArch64ISD::EXPAND_ZA_BUFFER, DL,
+                           DAG.getVTList(MVT::i64, MVT::Other), {Chain, Size});
+    } else {
+      Buffer = DAG.getNode(ISD::DYNAMIC_STACKALLOC, DL,
+                           DAG.getVTList(MVT::i64, MVT::Other),
+                           {Chain, Size, DAG.getConstant(1, DL, MVT::i64)});
+      MFI.CreateVariableSizedObject(Align(1), nullptr);
----------------
sdesmalen-arm wrote:

nit:
```suggestion
      MFI.CreateVariableSizedObject(Align(16), nullptr);
```
It shouldn't impact codegen, but it's more correct. Unfortunately, we can't change the `DAG.getConstant(1, ..) -> 16, because the code doesn't know that Size is already a multiple of 16.

https://github.com/llvm/llvm-project/pull/81648


More information about the llvm-commits mailing list