[llvm] [AArch64][SME] Support saving/restoring ZT0 in the MachineSMEABIPass (PR #166362)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 04:59:04 PST 2025


================
@@ -221,18 +248,39 @@ static bool isZAorZTRegOp(const TargetRegisterInfo &TRI,
 /// Returns the required ZA state needed before \p MI and an iterator pointing
 /// to where any code required to change the ZA state should be inserted.
 static std::pair<ZAState, MachineBasicBlock::iterator>
-getZAStateBeforeInst(const TargetRegisterInfo &TRI, MachineInstr &MI,
-                     bool ZAOffAtReturn) {
+getInstNeededZAState(const TargetRegisterInfo &TRI, MachineInstr &MI,
+                     SMEAttrs SMEFnAttrs) {
   MachineBasicBlock::iterator InsertPt(MI);
 
+  // Note: InOutZAUsePseudo, RequiresZASavePseudo, and RequiresZT0SavePseudo are
+  // intended to mark the position immediately before a call. Due to
+  // SelectionDAG constraints, these markers occur after the ADJCALLSTACKDOWN,
+  // so we use std::prev(InsertPt) to get the position before the call.
----------------
MacDue wrote:

There already is an assert for this:

https://github.com/llvm/llvm-project/blob/2b8d363ac1a8cca21c32afc039cb28f0f1608300/llvm/lib/Target/AArch64/MachineSMEABIPass.cpp#L434-L437

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


More information about the llvm-commits mailing list