[llvm] r270099 - [Target] Don't return a std::string in getRegAsmName

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 13:03:16 PDT 2016


Author: majnemer
Date: Thu May 19 15:03:16 2016
New Revision: 270099

URL: http://llvm.org/viewvc/llvm-project?rev=270099&view=rev
Log:
[Target] Don't return a std::string in getRegAsmName

getRegAsmName ends up making a copy of the register's name in order to
make a lower-case version of it.  This is bad because
getRegForInlineAsmConstraint, it's sole caller, does a lowercase
comparison anyway.

This resulted in a significant regression in compile time for the Linux
kernel because getRegAsmName is called in a loop by
getRegForInlineAsmConstraint.

Instead, forgo the call to lower in getRegAsmName and have it return a
StringRef.

No functionality change is intended.

Modified:
    llvm/trunk/include/llvm/Target/TargetRegisterInfo.h

Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=270099&r1=270098&r2=270099&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Thu May 19 15:03:16 2016
@@ -902,14 +902,14 @@ public:
                                    RegScavenger *RS = nullptr) const = 0;
 
   /// Return the assembly name for \p Reg.
-  virtual std::string getRegAsmName(unsigned Reg) const {
+  virtual StringRef getRegAsmName(unsigned Reg) const {
     // FIXME: We are assuming that the assembly name is equal to the TableGen
     // name converted to lower case
     //
     // The TableGen name is the name of the definition for this register in the
     // target's tablegen files.  For example, the TableGen name of
     // def EAX : Register <...>; is "EAX"
-    return StringRef(getName(Reg)).lower();
+    return StringRef(getName(Reg));
   }
 
   //===--------------------------------------------------------------------===//




More information about the llvm-commits mailing list