[clang] [Clang][SME] Detect always_inline used with mismatched streaming attributes (PR #77936)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 06:57:20 PST 2024


================
@@ -812,6 +819,24 @@ Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
                           /*allowHigherAlign*/ false);
 }
 
+void AArch64TargetCodeGenInfo::checkFunctionCallABI(
+    CodeGenModule &CGM, SourceLocation CallLoc, const FunctionDecl *Caller,
+    const FunctionDecl *Callee, const CallArgList &Args) const {
+  if (!Callee->hasAttr<AlwaysInlineAttr>())
+    return;
+
+  auto CalleeStreamingMode = Sema::getArmStreamingFnType(Callee);
+  auto CallerStreamingMode = Sema::getArmStreamingFnType(Caller);
+
+  // The caller can inline the callee if their streaming modes match or the
+  // callee is streaming compatible
+  if (CalleeStreamingMode != CallerStreamingMode &&
----------------
sdesmalen-arm wrote:

Can you use the llvm::AArch64::SMEAttrs class and reuse some of the same functionality as we have in `AArch64TTIImpl::areInlineCompatible` (ignoring the `hasPossibleIncompatibleOps` part).

That way, we can also check for ZA, e.g. 
```
__attribute__((always_inline)) __arm_new("za")
void bar(void)  { }

void foo() { bar(); }
```

here `bar` cannot be inlined because that would require making `foo` `__arm_new("za")` as well.

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


More information about the cfe-commits mailing list