[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 09:35:08 PDT 2024


================
@@ -14266,6 +14277,71 @@ CodeGenFunction::EmitAArch64CpuSupports(ArrayRef<StringRef> FeaturesStrs) {
   return Result;
 }
 
+Value *CodeGenFunction::EmitRISCVCpuSupports(ArrayRef<StringRef> FeaturesStrs,
+                                             unsigned &MaxGroupIDUsed) {
+
+  const unsigned FeatureBitSize = llvm::RISCV::RISCVFeatureBitSize;
----------------
preames wrote:

This block of repeating code should be factored out as a static helper.

However, you appear to be missing a very important detail.  This symbol must be a weak symbol, and the client code must bail if the weak symbol resolves to nullptr.  Otherwise we have a *hard* dependency on the compiler-rt/libgcc version as opposed to a soft dependency.  We want this to simply select the default implementation if the libgcc version does not support the new feature.

(I'm a bit unclear on the semantics of a weak global vs a weak function.  We may want to use a check on one of the symbols instead.)

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


More information about the llvm-commits mailing list