[X86] Remove a couple temporary std::string for CPU names that I don't need to exist.
authorCraig Topper <craig.topper@intel.com>
Wed, 22 Jul 2020 22:44:41 +0000 (15:44 -0700)
committerCraig Topper <craig.topper@intel.com>
Wed, 22 Jul 2020 22:55:04 +0000 (15:55 -0700)
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
llvm/lib/Target/X86/X86Subtarget.cpp

index 81110ba..8a47835 100644 (file)
@@ -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() {
index 975cbab..8a2d113 100644 (file)
@@ -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