[clang] [clang][FMV][AArch64] Improve streaming mode compatibility. (PR #100181)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 24 06:50:12 PDT 2024


================
@@ -11145,7 +11148,24 @@ bool Sema::areMultiversionVariantFunctionsCompatible(
     FunctionType::ExtInfo OldTypeInfo = OldType->getExtInfo();
     FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
 
-    if (OldTypeInfo.getCC() != NewTypeInfo.getCC())
+    const auto *OldFPT = OldFD->getType()->getAs<FunctionProtoType>();
+    const auto *NewFPT = NewFD->getType()->getAs<FunctionProtoType>();
+
+    bool ArmStreamingCCMismatched = false;
+    // Locally streaming does not affect the calling convention.
+    if (OldFPT && NewFPT && !OldFD->hasAttr<ArmLocallyStreamingAttr>() &&
+        !NewFD->hasAttr<ArmLocallyStreamingAttr>()) {
----------------
sdesmalen-arm wrote:

> Are you saying that ok_arm_streaming and ok_arm_streaming_compatible from my example in clang/test/Sema/aarch64-fmv-streaming.c should report an error? 

Yes, that's right, that is because for:
```
(A) __attribute__((target_clones("sve", "simd"))) void ok_arm_streaming(void) __arm_streaming {}
(B) __arm_locally_streaming __attribute__((target_version("sme2"))) void ok_arm_streaming(void) {}
```
(A) needs to be called in streaming mode, whereas (B) should be called in non-streaming mode.

I also think that the following case should give a diagnostic:
```
__attribute__((target_clones("sve", "simd"))) void bad_mixed_streaming2(void) {}

// expected-error at +1 {{multiversioned function declaration has a different calling convention}}
__arm_locally_streaming __attribute__((target_version("sme2"))) void bad_mixed_streaming2(void) __arm_streaming {}
```

The check for `__arm_locally_streaming` prevents that at the moment.

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


More information about the cfe-commits mailing list