[llvm] 8750d54 - [X86][AutoUpgrade] Simplify string management in UpgradeDataLayoutString a bit. NFCI

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 17:48:44 PDT 2020


Author: Craig Topper
Date: 2020-08-19T17:48:11-07:00
New Revision: 8750d54cea31751fbf1dbcb03b7569493769fdef

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

LOG: [X86][AutoUpgrade] Simplify string management in UpgradeDataLayoutString a bit. NFCI

We don't need a std::string for a literal string, we can use a
StringRef.

The addition of StringRefs produces a Twine that we can just call
str() without converting to a SmallString ourselves. Twine will
do that internally.

Added: 
    

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index dfe05c023b94..581778c9c678 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4308,7 +4308,7 @@ MDNode *llvm::upgradeInstructionLoopAttachment(MDNode &N) {
 }
 
 std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
-  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
+  StringRef AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
 
   // If X86, and the datalayout matches the expected format, add pointer size
   // address spaces to the datalayout.
@@ -4320,9 +4320,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
   if (!R.match(DL, &Groups))
     return std::string(DL);
 
-  SmallString<1024> Buf;
-  std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str();
-  return Res;
+  return (Groups[1] + AddrSpaces + Groups[3]).str();
 }
 
 void llvm::UpgradeAttributes(AttrBuilder &B) {


        


More information about the llvm-commits mailing list