[X86] Make getX86TargetCPU return std::string instead of const char *. Remove call to MakeArgString. NFCI

I believe this function used to be called directly from X86
specific code and was used to immediately create -target-cpu
command line. A later refactoring changed it to to be called from
a generic getCPU function that returns std::string. So on some
paths we created a string using MakeArgString converted that to
std::string then called MakeArgString again from that.

Instead just return std::string directly like the other targets.
This commit is contained in:
Craig Topper 2020-08-06 09:23:22 -07:00
parent 87cba43402
commit e1cad4234c
2 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ using namespace clang::driver::tools;
using namespace clang;
using namespace llvm::opt;
const char *x86::getX86TargetCPU(const ArgList &Args,
std::string x86::getX86TargetCPU(const ArgList &Args,
const llvm::Triple &Triple) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
if (StringRef(A->getValue()) != "native")
@ -33,7 +33,7 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
// with -native.
std::string CPU = std::string(llvm::sys::getHostCPUName());
if (!CPU.empty() && CPU != "generic")
return Args.MakeArgString(CPU);
return CPU;
}
if (const Arg *A = Args.getLastArgNoClaim(options::OPT__SLASH_arch)) {
@ -64,7 +64,7 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
// Select the default CPU if none was given (or detection failed).
if (!Triple.isX86())
return nullptr; // This routine is only handling x86 targets.
return ""; // This routine is only handling x86 targets.
bool Is64Bit = Triple.getArch() == llvm::Triple::x86_64;

View File

@ -21,7 +21,7 @@ namespace driver {
namespace tools {
namespace x86 {
const char *getX86TargetCPU(const llvm::opt::ArgList &Args,
std::string getX86TargetCPU(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple);
void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,