diff options
author | Matthew Devereau <matthew.devereau@arm.com> | 2025-05-16 09:39:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-16 09:39:07 +0100 |
commit | 22576e2ccec60af6d27d8fd95ad3ca721b914815 (patch) | |
tree | 21f98aff874e1c010df39b877cd5b0a71835838b /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | aacebaeab5448b4ef614aa8aca52ca210e451f79 (diff) | |
download | llvm-22576e2ccec60af6d27d8fd95ad3ca721b914815.zip llvm-22576e2ccec60af6d27d8fd95ad3ca721b914815.tar.gz llvm-22576e2ccec60af6d27d8fd95ad3ca721b914815.tar.bz2 |
[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.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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<bool> FeatureMap; + bool IsArmStreaming = false; + if (FD) { + getContext().getFunctionFeatureMap(FeatureMap, FD); + IsArmStreaming = IsArmStreamingFunction(FD, true); + } std::optional<std::pair<unsigned, unsigned>> 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)); |