[clang] [Clang][AArch64] Add pessimistic vscale_range when sve is in target-f… (PR #137624)

Matthew Devereau via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 28 08:16:07 PDT 2025


================
@@ -794,14 +795,22 @@ AArch64TargetInfo::getTargetBuiltins() const {
 
 std::optional<std::pair<unsigned, unsigned>>
 AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts,
-                                  bool IsArmStreamingFunction) const {
+                                  bool IsArmStreamingFunction,
+                                  llvm::Function *F) const {
   if (LangOpts.VScaleMin || LangOpts.VScaleMax)
     return std::pair<unsigned, unsigned>(
         LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
 
   if (hasFeature("sve") || (IsArmStreamingFunction && hasFeature("sme")))
     return std::pair<unsigned, unsigned>(1, 16);
 
+  if (F && F->hasFnAttribute("target-features")) {
+    StringRef Str = F->getFnAttribute("target-features").getValueAsString();
+    for (const auto &s : llvm::split(Str, ",")) {
+      if (s == "+sve")
----------------
MDevereau wrote:

I agree it makes sense, but the reason I hesitated was IsArmStreamingFunction looks like it could become an internal function of FunctionDecl which should help keep CodeGenFunction.cpp target agnostic. I thought it might be better to submit the changes to SME streaming mode as a separate patch.

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


More information about the cfe-commits mailing list