[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

Yingwei Zheng via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 10 21:46:04 PDT 2024


================
@@ -86,8 +86,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   // and other features (ex. mirco architecture feature) from mcpu
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
     StringRef CPU = A->getValue();
-    if (CPU == "native")
+    if (CPU == "native") {
       CPU = llvm::sys::getHostCPUName();
+      llvm::StringMap<bool> HostFeatures;
+      if (llvm::sys::getHostCPUFeatures(HostFeatures))
----------------
dtcxzyw wrote:

I think hwprobe is more reliable than cpu name because some RV cpus are not recognized by LLVM (e.g., T-head's cores). However, cpu name is still useful even if `getHostCPUFeatures` returns true because it may provide scheduling model.


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


More information about the cfe-commits mailing list