[clang] [clang][SME] Ignore flatten/clang::always_inline statements for callees with mismatched streaming attributes (PR #116391)
Sander de Smalen via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 26 05:26:45 PST 2024
================
@@ -1143,30 +1146,63 @@ void AArch64TargetCodeGenInfo::checkFunctionABI(
}
}
-void AArch64TargetCodeGenInfo::checkFunctionCallABIStreaming(
- CodeGenModule &CGM, SourceLocation CallLoc, const FunctionDecl *Caller,
- const FunctionDecl *Callee) const {
- if (!Caller || !Callee || !Callee->hasAttr<AlwaysInlineAttr>())
- return;
+enum class ArmSMEInlinability : uint8_t {
+ Ok = 0,
+ MismatchedStreamingCompatibility = 1 << 0,
+ IncompatibleStreamingModes = 1 << 1,
+ CalleeRequiresNewZA = 1 << 2,
+ LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/CalleeRequiresNewZA),
+};
+/// Determines if there are any Arm SME ABI issues with inlining \p Callee into
+/// \p Caller. Returns the issues in the ArmSMEInlinability bit enum (multiple
+/// bits can be set).
+static ArmSMEInlinability GetArmSMEInlinability(const FunctionDecl *Caller,
+ const FunctionDecl *Callee) {
bool CallerIsStreaming =
IsArmStreamingFunction(Caller, /*IncludeLocallyStreaming=*/true);
bool CalleeIsStreaming =
IsArmStreamingFunction(Callee, /*IncludeLocallyStreaming=*/true);
bool CallerIsStreamingCompatible = isStreamingCompatible(Caller);
bool CalleeIsStreamingCompatible = isStreamingCompatible(Callee);
+ ArmSMEInlinability Inlinability = ArmSMEInlinability::Ok;
+
if (!CalleeIsStreamingCompatible &&
- (CallerIsStreaming != CalleeIsStreaming || CallerIsStreamingCompatible))
- CGM.getDiags().Report(
- CallLoc, CalleeIsStreaming
- ? diag::err_function_always_inline_attribute_mismatch
- : diag::warn_function_always_inline_attribute_mismatch)
- << Caller->getDeclName() << Callee->getDeclName() << "streaming";
+ (CallerIsStreaming != CalleeIsStreaming || CallerIsStreamingCompatible)) {
+ Inlinability |= ArmSMEInlinability::MismatchedStreamingCompatibility;
+ if (CalleeIsStreaming)
+ Inlinability |= ArmSMEInlinability::IncompatibleStreamingModes;
+ }
if (auto *NewAttr = Callee->getAttr<ArmNewAttr>())
if (NewAttr->isNewZA())
- CGM.getDiags().Report(CallLoc, diag::err_function_always_inline_new_za)
- << Callee->getDeclName();
+ Inlinability |= ArmSMEInlinability::CalleeRequiresNewZA;
+
+ return Inlinability;
+}
+
+void AArch64TargetCodeGenInfo::checkFunctionCallABIStreaming(
+ CodeGenModule &CGM, SourceLocation CallLoc, const FunctionDecl *Caller,
+ const FunctionDecl *Callee) const {
+ if (!Caller || !Callee || !Callee->hasAttr<AlwaysInlineAttr>())
+ return;
+
+ ArmSMEInlinability Inlinability = GetArmSMEInlinability(Caller, Callee);
+
+ if ((Inlinability & ArmSMEInlinability::MismatchedStreamingCompatibility) !=
+ ArmSMEInlinability::Ok)
+ CGM.getDiags().Report(
+ CallLoc,
+ (Inlinability & ArmSMEInlinability::IncompatibleStreamingModes) !=
+ ArmSMEInlinability::Ok
----------------
sdesmalen-arm wrote:
nit:
```suggestion
(Inlinability & ArmSMEInlinability::IncompatibleStreamingModes) ==
ArmSMEInlinability::IncompatibleStreamingModes
```
https://github.com/llvm/llvm-project/pull/116391
More information about the cfe-commits
mailing list