[PATCH] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 4 02:23:00 PST 2023


kito-cheng added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5457
+  // RISC-V will handle -mcpu option in Clang::AddRISCVTargetArgs.
+  if (!Triple.isRISCV()) {
+    // Add the target cpu
----------------
craig.topper wrote:
> kito-cheng wrote:
> > craig.topper wrote:
> > > I wonder if we should stop getCPUName from calling `getRISCVTargetCPU` instead? Have you audited all callers of getCPUName?
> > That sounds a better way, that prevent us to auditing every caller of `getCPUName`.
> I think we need to do the audit either way.
28 call site in clang, search by `$ grep [^r]getCPUName * -R -n`

$ grep [^r]getCPUName * -R -n 
Reviewed and seems OK:
 - Clang::ConstructJob: lib/Driver/ToolChains/Clang.cpp:5438:        getCPUName(D, HostArgs, *TC.getAuxTriple(), /*FromAs*/ false);
 - ClangAs::ConstructJob: lib/Driver/ToolChains/Clang.cpp:7880:  std::string CPU = getCPUName(D, Args, Triple, /*FromAs*/ true);
 - -aux-target-cpu: lib/Driver/ToolChains/Clang.cpp:5480:  std::string CPU = getCPUName(D, Args, Triple, /*FromAs*/ false);

Should fix:
- tools::addLTOOptions: lib/Driver/ToolChains/CommonArgs.cpp:630:  std::string CPU = getCPUName(D, Args, ToolChain.getTriple());

Should fix in future, because we don't really port that part for RISC-V:
- lib/Driver/ToolChains/Flang.cpp:89:  std::string CPU = getCPUName(D, Args, Triple);

x86 specific cpu_specific attribute:
 - include/clang/Basic/Attr.td:1136:    IdentifierInfo *getCPUName(unsigned Index) const {
 - lib/CodeGen/CodeGenModule.cpp:1336:    Out << getCPUSpecificMangling(CGM, Attr->getCPUName(CPUIndex)->getName());
 - lib/CodeGen/CodeGenModule.cpp:2202:          SD->getCPUName(GD.getMultiVersionIndex())->getName());
 - lib/AST/ASTContext.cpp:13386:        SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);

Target specific:
 - lib/Driver/ToolChains/AVR.cpp:372:  if (getCPUName(D, Args, Triple).empty())
 - lib/Driver/ToolChains/AVR.cpp:445:  std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
 - lib/Driver/ToolChains/Arch/Mips.cpp:453:  return llvm::StringSwitch<bool>(getCPUName(D, Args, Triple))
 - lib/Driver/ToolChains/Arch/AArch64.cpp:623:    std::string CPU = getCPUName(D, Args, Triple);

 - Sparc:
   - lib/Driver/ToolChains/OpenBSD.cpp:64:    std::string CPU = getCPUName(D, Args, Triple);
   - lib/Driver/ToolChains/FreeBSD.cpp:103:    std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
 - aarch64: lib/Driver/ToolChains/Gnu.cpp:461:    std::string CPU = getCPUName(D, Args, Triple);
 - PPC: lib/Driver/ToolChains/Gnu.cpp:760:        getCPUName(D, Args, getToolChain().getTriple())));
 - PPCLE: lib/Driver/ToolChains/Gnu.cpp:768:        getCPUName(D, Args, getToolChain().getTriple())));
 - PPC64: lib/Driver/ToolChains/Gnu.cpp:776:        getCPUName(D, Args, getToolChain().getTriple())));
 - PPC64LE: lib/Driver/ToolChains/Gnu.cpp:784:        getCPUName(D, Args, getToolChain().getTriple())));
 - SPARC: lib/Driver/ToolChains/Gnu.cpp:819:    std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
 - SPARCv9: lib/Driver/ToolChains/Gnu.cpp:827:    std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
 - ARM: lib/Driver/ToolChains/Clang.cpp:1548:    std::string CPU = getCPUName(D, Args, Triple, /*FromAs*/ false);
 - AArch64: lib/Driver/ToolChains/Fuchsia.cpp:92:    std::string CPU = getCPUName(D, Args, Triple);
 - Sparc: lib/Driver/ToolChains/NetBSD.cpp:83:    std::string CPU = getCPUName(D, Args, Triple);
 - Sparcv9: lib/Driver/ToolChains/NetBSD.cpp:91:    std::string CPU = getCPUName(D, Args, Triple);

Declaration:
 - lib/Driver/ToolChains/CommonArgs.h:174:std::string getCPUName(const Driver &D, const llvm::opt::ArgList &Args,
Implement 
 - lib/Driver/ToolChains/CommonArgs.cpp:363:std::string tools::getCPUName(const Driver &D, const ArgList &Args,


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140693/new/

https://reviews.llvm.org/D140693



More information about the cfe-commits mailing list