================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to