[clang] [llvm] [NFC][clang][FMV][TargetInfo] Refactor API for FMV feature priority. (PR #116257)
Alexandros Lamprineas via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 18 03:48:34 PST 2024
================
@@ -4216,22 +4216,11 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
llvm::Function *NewFn);
static unsigned
-TargetMVPriority(const TargetInfo &TI,
- const CodeGenFunction::MultiVersionResolverOption &RO) {
- unsigned Priority = 0;
- unsigned NumFeatures = 0;
- for (StringRef Feat : RO.Conditions.Features) {
- Priority = std::max(Priority, TI.multiVersionSortPriority(Feat));
- NumFeatures++;
- }
-
- if (!RO.Conditions.Architecture.empty())
- Priority = std::max(
- Priority, TI.multiVersionSortPriority(RO.Conditions.Architecture));
-
- Priority += TI.multiVersionFeatureCost() * NumFeatures;
-
- return Priority;
+getFMVPriority(const TargetInfo &TI,
+ const CodeGenFunction::MultiVersionResolverOption &RO) {
+ llvm::SmallVector<StringRef, 8> Features{RO.Conditions.Features};
+ Features.push_back(RO.Conditions.Architecture);
+ return TI.getFMVPriority(Features);
----------------
labrinea wrote:
> RO.Conditions.Architecture isn't suitable for AArch64, and correct me if I am wrong but so far it doesn't seem that risc-v is using it either?
Ok, looking at `clang/test/CodeGen/attr-target-version-riscv.c` I can see that riscv does support `arch` but line https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L4297 suggests that RO.Conditions.Architecture is empty for the riscv target? That seems odd.
I guess this arrises from the fact that on AArch64 and x86, features are split by '+' whereas on riscv they split by ';'. The argument `ArrayRef<StringRef>` I am using suggests that the attribute string has been parsed for the other targets, which isn't the case for riscv. That doesn't seem right either:
line https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L4292 appends an unparsed string to a list of parsed features.
https://github.com/llvm/llvm-project/pull/116257
More information about the cfe-commits
mailing list