From: Fangrui Song Date: Wed, 10 Apr 2019 14:52:37 +0000 (+0000) Subject: [MachineOutliner] Replace ostringstream based string concatenation with Twine X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5abf2be60cb91995feda8a6a7e3c994323e2d29c;p=llvm [MachineOutliner] Replace ostringstream based string concatenation with Twine This makes my libLLVMCodeGen.so.9svn 4936 bytes smaller. While here, delete unused #include git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358089 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineOutliner.cpp b/lib/CodeGen/MachineOutliner.cpp index 8c0626092bb..7b1750a170d 100644 --- a/lib/CodeGen/MachineOutliner.cpp +++ b/lib/CodeGen/MachineOutliner.cpp @@ -73,8 +73,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include -#include -#include #include #include @@ -1094,19 +1092,15 @@ MachineOutliner::createOutlinedFunction(Module &M, OutlinedFunction &OF, 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.