From 8750d54cea31751fbf1dbcb03b7569493769fdef Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 19 Aug 2020 17:44:21 -0700 Subject: [PATCH] [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. --- llvm/lib/IR/AutoUpgrade.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index dfe05c0..581778c 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) { -- 2.7.4