[llvm] [AArch64] SME implementation for agnostic-ZA functions (PR #120150)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 08:44:38 PST 2024


================
@@ -240,6 +240,17 @@ static bool hasPossibleIncompatibleOps(const Function *F) {
           (cast<CallInst>(I).isInlineAsm() || isa<IntrinsicInst>(I) ||
            isSMEABIRoutineCall(cast<CallInst>(I))))
         return true;
+
+      if (auto *CB = dyn_cast<CallBase>(&I)) {
+        SMEAttrs CallerAttrs(*CB->getCaller()),
+            CalleeAttrs(*CB->getCalledFunction());
+        // When trying to determine if we can inline callees, we must check
+        // that for agnostic-ZA functions, they don't call any functions
+        // that are not agnostic-ZA, as that would require inserting of
+        // save/restore code.
----------------
sdesmalen-arm wrote:

> What problem is this solving? If we inline calls that might clobber za in a context where za is not live, it doesn't matter. If we inline calls that might clobber za into a context where za might be live, we'll insert save/restore calls.

Thanks for pointing out. You're right that this change made no sense and can be removed.

> If we care about reducing the number of save/restore calls, we can change code generation to remove redundant restore/save pairs. (We can use a dataflow analysis after isel.)

The expectation is that this is mostly used for leaf functions, or otherwise for functions where the transitive closure of callees is also agnostic-ZA. Calls to private-ZA functions would be expensive and therefore limited to debug routines in practice, which would probably be executed under a condition.

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


More information about the llvm-commits mailing list