From 22576e2ccec60af6d27d8fd95ad3ca721b914815 Mon Sep 17 00:00:00 2001 From: Matthew Devereau Date: Fri, 16 May 2025 09:39:07 +0100 Subject: [Clang][AArch64] Add pessimistic vscale_range for sve/sme (#137624) The "target-features" function attribute is not currently considered when adding vscale_range to a function. When +sve/+sme are pushed onto functions with "#pragma attribute push(+sve/+sme)", the function potentially misses out on optimizations that rely on vscale_range being present. --- clang/lib/CodeGen/CodeGenFunction.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index d773cdd..ac40aab 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1115,9 +1115,15 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, Fn->removeFnAttr("zero-call-used-regs"); // Add vscale_range attribute if appropriate. + llvm::StringMap FeatureMap; + bool IsArmStreaming = false; + if (FD) { + getContext().getFunctionFeatureMap(FeatureMap, FD); + IsArmStreaming = IsArmStreamingFunction(FD, true); + } std::optional> VScaleRange = - getContext().getTargetInfo().getVScaleRange( - getLangOpts(), FD ? IsArmStreamingFunction(FD, true) : false); + getContext().getTargetInfo().getVScaleRange(getLangOpts(), IsArmStreaming, + &FeatureMap); if (VScaleRange) { CurFn->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs( getLLVMContext(), VScaleRange->first, VScaleRange->second)); -- cgit v1.1