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

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 01:19:20 PST 2024


================
@@ -7051,10 +7115,14 @@ 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);
+    Chain = SDValue(
----------------
sdesmalen-arm wrote:

When I try this patch on a trivial example (foo() with ZA state calling bar() that doesn't use ZA)

I see:
```
bb.0 (%ir-block.0):
  ExpandZABuffer
  ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
  BL @bar, <regmask $fp $lr $wzr $xzr $b8 ...>, implicit-def dead $lr, implicit $sp, implicit-def $sp
  ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
  RET_ReallyLR
```

I think that at the very least `ExpandZABuffer` should add an `implicit-def` of `$sp` and an implicit use of `$sp`, because it reads and modifies the stack pointer.

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


More information about the llvm-commits mailing list