[clang] [Clang][AArch64] Warn when calling streaming/non-streaming about vect… (PR #79842)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 00:38:35 PST 2024


================
@@ -7513,6 +7516,41 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
       }
     }
 
+    auto *CallerFD = dyn_cast<FunctionDecl>(CurContext);
+    bool IsCalleeStreaming = ((ExtInfo.AArch64SMEAttributes &
+                               FunctionType::SME_PStateSMEnabledMask) ||
+                              (ExtInfo.AArch64SMEAttributes &
+                               FunctionType::SME_PStateSMCompatibleMask));
+    bool IsBuiltin = (FD && FD->getBuiltinID());
+
+    if (CallerFD && Context.getTargetInfo().hasFeature("sme") && !IsBuiltin) {
+      // If the callee has an AArch64 SME __arm_locally_streaming attribute
+      // warn if this function returns VL-based value or pass any such argument,
+      // the streaming and non-streaming vector lengths may be different.
+      ArmStreamingType CallerFnType = getArmStreamingFnType(CallerFD);
+      // If the caller is a non-streaming function and the callee has a
+      // streaming attribute. If it passed any VL-based arguments or return
+      // VL-based value, then warn that the streaming and non-streaming vector
+      // lengths may be different.
+      if (CallerFnType != ArmStreaming) {
+        if (IsCalleeStreaming) {
+          if (AnyScalableArgs)
+            Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
+          if (Proto->getReturnType()->isSizelessVectorType())
+            Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
+        }
+      } else if (!IsCalleeStreaming) {
+        // If the callee is a non-streaming function and the caller has
+        // streaming attribute. If it passed any VL-based arguments or return
+        // VL-based value, then warn that the streaming and non-streaming vector
+        // lengths may be different.
+        if (AnyScalableArgs)
+          Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
+        if (Proto->getReturnType()->isSizelessVectorType())
+          Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
+      }
----------------
sdesmalen-arm wrote:

Does this code support the following case:

```
void test_sc_to_n(sv_ty arg) __arm_streaming_compatible { n(arg); } // expect a diagnostic
```

?

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


More information about the cfe-commits mailing list