From deeb2fdbf4d9d805d2709bb7912cb596b4a90750 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 22 Jul 2020 15:44:41 -0700 Subject: [PATCH] [X86] Remove a couple temporary std::string for CPU names that I don't need to exist. The input to these functions is a StringRef. We then convert it to a std::string. Then maybe replace with "generic". I think we can just overwrite the incoming StringRef with "generic" if needed and then pass it along without creating any std::string. --- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp | 7 +++---- llvm/lib/Target/X86/X86Subtarget.cpp | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index 81110ba..8a47835 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -290,11 +290,10 @@ MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(const Triple &TT, if (!FS.empty()) ArchFS = (Twine(ArchFS) + "," + FS).str(); - std::string CPUName = std::string(CPU); - if (CPUName.empty()) - CPUName = "generic"; + if (CPU.empty()) + CPU = "generic"; - return createX86MCSubtargetInfoImpl(TT, CPUName, ArchFS); + return createX86MCSubtargetInfoImpl(TT, CPU, ArchFS); } static MCInstrInfo *createX86MCInstrInfo() { diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index 975cbab..8a2d113 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -228,9 +228,8 @@ bool X86Subtarget::isLegalToCallImmediateAddr() const { } void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { - std::string CPUName = std::string(CPU); - if (CPUName.empty()) - CPUName = "generic"; + if (CPU.empty()) + CPU = "generic"; std::string FullFS = std::string(FS); if (In64BitMode) { @@ -242,7 +241,7 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { FullFS = "+sse2"; // If no CPU was specified, enable 64bit feature to satisy later check. - if (CPUName == "generic") { + if (CPU == "generic") { if (!FullFS.empty()) FullFS = "+64bit," + FullFS; else @@ -259,7 +258,7 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { } // Parse features string and set the CPU. - ParseSubtargetFeatures(CPUName, FullFS); + ParseSubtargetFeatures(CPU, FullFS); // All CPUs that implement SSE4.2 or SSE4A support unaligned accesses of // 16-bytes and under that are reasonably fast. These features were -- 2.7.4