llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Yingwei Zheng (dtcxzyw) <details> <summary>Changes</summary> See the discussion in https://github.com/llvm/llvm-project/pull/94352#discussion_r1657074801 --- Full diff: https://github.com/llvm/llvm-project/pull/97965.diff 7 Files Affected: - (modified) clang/lib/Driver/Driver.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+5-5) - (modified) clang/lib/Driver/ToolChains/Arch/RISCV.h (+2-2) - (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+4-3) ``````````diff diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 221e222bdd47d9..021c5b8a33dba9 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -681,7 +681,7 @@ static llvm::Triple computeTargetTriple(const Driver &D, if (Target.isRISCV()) { if (Args.hasArg(options::OPT_march_EQ) || Args.hasArg(options::OPT_mcpu_EQ)) { - StringRef ArchName = tools::riscv::getRISCVArch(Args, Target); + std::string ArchName = tools::riscv::getRISCVArch(Args, Target); auto ISAInfo = llvm::RISCVISAInfo::parseArchString( ArchName, /*EnableExperimentalExtensions=*/true); if (!llvm::errorToBool(ISAInfo.takeError())) { diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 26789b0ba6e098..1831a4113fcd08 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -72,7 +72,7 @@ static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A, void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, const ArgList &Args, std::vector<StringRef> &Features) { - StringRef MArch = getRISCVArch(Args, Triple); + std::string MArch = getRISCVArch(Args, Triple); if (!getArchFeatures(D, MArch, Features, Args)) return; @@ -227,7 +227,7 @@ StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) { // rv64g | rv64*d -> lp64d // rv64e -> lp64e // rv64* -> lp64 - StringRef Arch = getRISCVArch(Args, Triple); + std::string Arch = getRISCVArch(Args, Triple); auto ParseResult = llvm::RISCVISAInfo::parseArchString( Arch, /* EnableExperimentalExtension */ true); @@ -253,8 +253,8 @@ StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) { } } -StringRef riscv::getRISCVArch(const llvm::opt::ArgList &Args, - const llvm::Triple &Triple) { +std::string riscv::getRISCVArch(const llvm::opt::ArgList &Args, + const llvm::Triple &Triple) { assert(Triple.isRISCV() && "Unexpected triple"); // GCC's logic around choosing a default `-march=` is complex. If GCC is not @@ -295,7 +295,7 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList &Args, StringRef MArch = llvm::RISCV::getMArchFromMcpu(CPU); // Bypass if target cpu's default march is empty. if (MArch != "") - return MArch; + return MArch.str(); } // 3. Choose a default based on `-mabi=` diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.h b/clang/lib/Driver/ToolChains/Arch/RISCV.h index fcaf9d57ad13d6..388786b9c4c1f4 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.h +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.h @@ -24,8 +24,8 @@ void getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, std::vector<llvm::StringRef> &Features); StringRef getRISCVABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple); -StringRef getRISCVArch(const llvm::opt::ArgList &Args, - const llvm::Triple &Triple); +std::string getRISCVArch(const llvm::opt::ArgList &Args, + const llvm::Triple &Triple); std::string getRISCVTargetCPU(const llvm::opt::ArgList &Args, const llvm::Triple &Triple); } // end namespace riscv diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 11f94877a5cff2..852e0442f50a23 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -37,7 +37,7 @@ static bool findRISCVMultilibs(const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args, DetectedMultilibs &Result) { Multilib::flags_list Flags; - StringRef Arch = riscv::getRISCVArch(Args, TargetTriple); + std::string Arch = riscv::getRISCVArch(Args, TargetTriple); StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple); if (TargetTriple.isRISCV64()) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index aa285c39f14b43..c43fd3def6db04 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2107,7 +2107,7 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args, // Get minimum VLen from march. unsigned MinVLen = 0; - StringRef Arch = riscv::getRISCVArch(Args, Triple); + std::string Arch = riscv::getRISCVArch(Args, Triple); auto ISAInfo = llvm::RISCVISAInfo::parseArchString( Arch, /*EnableExperimentalExtensions*/ true); // Ignore parsing error. diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 962a6c2c6b2984..ee8292a508f93c 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -204,7 +204,7 @@ void Flang::AddRISCVTargetArgs(const ArgList &Args, // Get minimum VLen from march. unsigned MinVLen = 0; - StringRef Arch = riscv::getRISCVArch(Args, Triple); + std::string Arch = riscv::getRISCVArch(Args, Triple); auto ISAInfo = llvm::RISCVISAInfo::parseArchString( Arch, /*EnableExperimentalExtensions*/ true); // Ignore parsing error. diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab1..d2a26c8091c484 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -769,9 +769,10 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C, StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple()); CmdArgs.push_back("-mabi"); CmdArgs.push_back(ABIName.data()); - StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple()); + std::string MArchName = + riscv::getRISCVArch(Args, getToolChain().getTriple()); CmdArgs.push_back("-march"); - CmdArgs.push_back(MArchName.data()); + CmdArgs.push_back(Args.MakeArgString(MArchName)); if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) Args.addOptOutFlag(CmdArgs, options::OPT_mrelax, options::OPT_mno_relax); break; @@ -1882,7 +1883,7 @@ static void findRISCVBareMetalMultilibs(const Driver &D, Multilib::flags_list Flags; llvm::StringSet<> Added_ABIs; StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple); - StringRef MArch = tools::riscv::getRISCVArch(Args, TargetTriple); + std::string MArch = tools::riscv::getRISCVArch(Args, TargetTriple); for (auto Element : RISCVMultilibSet) { addMultilibFlag(MArch == Element.march, Twine("-march=", Element.march).str().c_str(), Flags); `````````` </details> https://github.com/llvm/llvm-project/pull/97965 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits