[llvm] deeb2fd - [X86] Remove a couple temporary std::string for CPU names that I don't need to exist.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 15:56:01 PDT 2020


Author: Craig Topper
Date: 2020-07-22T15:55:04-07:00
New Revision: deeb2fdbf4d9d805d2709bb7912cb596b4a90750

URL: https://github.com/llvm/llvm-project/commit/deeb2fdbf4d9d805d2709bb7912cb596b4a90750
DIFF: https://github.com/llvm/llvm-project/commit/deeb2fdbf4d9d805d2709bb7912cb596b4a90750.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
    llvm/lib/Target/X86/X86Subtarget.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 81110ba666e9..8a478354cb16 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 975cbabb30fd..8a2d1130914e 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


        


More information about the llvm-commits mailing list