[llvm] r270270 - Address post-review for r270246

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 13:41:25 PDT 2016


Author: majnemer
Date: Fri May 20 15:41:24 2016
New Revision: 270270

URL: http://llvm.org/viewvc/llvm-project?rev=270270&view=rev
Log:
Address post-review for r270246

This gets rid of some unnecessary SmallStrings in
X86TargetMachine::getSubtargetImpl.

No functionality change is intended.

Modified:
    llvm/trunk/lib/Target/X86/X86TargetMachine.cpp

Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=270270&r1=270269&r2=270270&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri May 20 15:41:24 2016
@@ -182,12 +182,17 @@ X86TargetMachine::getSubtargetImpl(const
   Attribute CPUAttr = F.getFnAttribute("target-cpu");
   Attribute FSAttr = F.getFnAttribute("target-features");
 
-  SmallString<32> CPU = !CPUAttr.hasAttribute(Attribute::None)
-                            ? CPUAttr.getValueAsString()
-                            : (StringRef)TargetCPU;
-  SmallString<512> FS = !FSAttr.hasAttribute(Attribute::None)
-                            ? FSAttr.getValueAsString()
-                            : (StringRef)TargetFS;
+  StringRef CPU = !CPUAttr.hasAttribute(Attribute::None)
+                      ? CPUAttr.getValueAsString()
+                      : (StringRef)TargetCPU;
+  StringRef FS = !FSAttr.hasAttribute(Attribute::None)
+                     ? FSAttr.getValueAsString()
+                     : (StringRef)TargetFS;
+
+  SmallString<512> Key;
+  Key.reserve(CPU.size() + FS.size());
+  Key += CPU;
+  Key += FS;
 
   // FIXME: This is related to the code below to reset the target options,
   // we need to know whether or not the soft float flag is set on the
@@ -199,12 +204,9 @@ X86TargetMachine::getSubtargetImpl(const
   // If the soft float attribute is set on the function turn on the soft float
   // subtarget feature.
   if (SoftFloat)
-    FS += FS.empty() ? "+soft-float" : ",+soft-float";
+    Key += FS.empty() ? "+soft-float" : ",+soft-float";
 
-  SmallString<544> Key;
-  Key.reserve(CPU.size() + FS.size());
-  Key += CPU;
-  Key += FS;
+  FS = Key.substr(CPU.size());
 
   auto &I = SubtargetMap[Key];
   if (!I) {




More information about the llvm-commits mailing list