[llvm] r358089 - [MachineOutliner] Replace ostringstream based string concatenation with Twine

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 07:52:38 PDT 2019


Author: maskray
Date: Wed Apr 10 07:52:37 2019
New Revision: 358089

URL: http://llvm.org/viewvc/llvm-project?rev=358089&view=rev
Log:
[MachineOutliner] Replace ostringstream based string concatenation with Twine

This makes my libLLVMCodeGen.so.9svn 4936 bytes smaller.

While here, delete unused #include <map>

Modified:
    llvm/trunk/lib/CodeGen/MachineOutliner.cpp

Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=358089&r1=358088&r2=358089&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Wed Apr 10 07:52:37 2019
@@ -73,8 +73,6 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include <functional>
-#include <map>
-#include <sstream>
 #include <tuple>
 #include <vector>
 
@@ -1094,19 +1092,15 @@ MachineOutliner::createOutlinedFunction(
                                         InstructionMapper &Mapper,
                                         unsigned Name) {
 
-  // Create the function name. This should be unique. For now, just hash the
-  // module name and include it in the function name plus the number of this
-  // function.
-  std::ostringstream NameStream;
+  // Create the function name. This should be unique.
   // FIXME: We should have a better naming scheme. This should be stable,
   // regardless of changes to the outliner's cost model/traversal order.
-  NameStream << "OUTLINED_FUNCTION_" << Name;
+  std::string FunctionName = ("OUTLINED_FUNCTION_" + Twine(Name)).str();
 
   // Create the function using an IR-level function.
   LLVMContext &C = M.getContext();
-  Function *F =
-      Function::Create(FunctionType::get(Type::getVoidTy(C), false),
-                       Function::ExternalLinkage, NameStream.str(), M);
+  Function *F = Function::Create(FunctionType::get(Type::getVoidTy(C), false),
+                                 Function::ExternalLinkage, FunctionName, M);
 
   // NOTE: If this is linkonceodr, then we can take advantage of linker deduping
   // which gives us better results when we outline from linkonceodr functions.




More information about the llvm-commits mailing list