diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/ProfileData/InstrProfReader.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/ProfileData/SampleProfReader.cpp | 4 | 
3 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 69bb9bb37b3..19b3f036b28 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -241,8 +241,7 @@ Error collectPGOFuncNameStrings(const std::vector<std::string> &NameStrs,    unsigned EncLen = encodeULEB128(UncompressedNameStrings.length(), P);    P += EncLen; -  auto WriteStringToResult = [&](size_t CompressedLen, -                                 const std::string &InputStr) { +  auto WriteStringToResult = [&](size_t CompressedLen, StringRef InputStr) {      EncLen = encodeULEB128(CompressedLen, P);      P += EncLen;      char *HeaderStr = reinterpret_cast<char *>(&Header[0]); @@ -256,7 +255,7 @@ Error collectPGOFuncNameStrings(const std::vector<std::string> &NameStrs,      return WriteStringToResult(0, UncompressedNameStrings);    } -  SmallVector<char, 128> CompressedNameStrings; +  SmallString<128> CompressedNameStrings;    zlib::Status Success =        zlib::compress(StringRef(UncompressedNameStrings), CompressedNameStrings,                       zlib::BestSizeCompression); @@ -264,9 +263,8 @@ Error collectPGOFuncNameStrings(const std::vector<std::string> &NameStrs,    if (Success != zlib::StatusOK)      return make_error<InstrProfError>(instrprof_error::compress_failed); -  return WriteStringToResult( -      CompressedNameStrings.size(), -      std::string(CompressedNameStrings.data(), CompressedNameStrings.size())); +  return WriteStringToResult(CompressedNameStrings.size(), +                             CompressedNameStrings);  }  StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar) { @@ -761,7 +759,7 @@ MDNode *getPGOFuncNameMetadata(const Function &F) {    return F.getMetadata(getPGOFuncNameMetadataName());  } -void createPGOFuncNameMetadata(Function &F, const std::string &PGOFuncName) { +void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName) {    // Only for internal linkage functions.    if (PGOFuncName == F.getName())        return; @@ -769,7 +767,7 @@ void createPGOFuncNameMetadata(Function &F, const std::string &PGOFuncName) {    if (getPGOFuncNameMetadata(F))      return;    LLVMContext &C = F.getContext(); -  MDNode *N = MDNode::get(C, MDString::get(C, PGOFuncName.c_str())); +  MDNode *N = MDNode::get(C, MDString::get(C, PGOFuncName));    F.setMetadata(getPGOFuncNameMetadataName(), N);  } diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index a7d8fcf76e1..81c13b35ce3 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -19,7 +19,7 @@  using namespace llvm;  static Expected<std::unique_ptr<MemoryBuffer>> -setupMemoryBuffer(std::string Path) { +setupMemoryBuffer(const Twine &Path) {    ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =        MemoryBuffer::getFileOrSTDIN(Path);    if (std::error_code EC = BufferOrErr.getError()) @@ -32,7 +32,7 @@ static Error initializeReader(InstrProfReader &Reader) {  }  Expected<std::unique_ptr<InstrProfReader>> -InstrProfReader::create(std::string Path) { +InstrProfReader::create(const Twine &Path) {    // Set up the buffer to read.    auto BufferOrError = setupMemoryBuffer(Path);    if (Error E = BufferOrError.takeError()) @@ -67,7 +67,7 @@ InstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) {  }  Expected<std::unique_ptr<IndexedInstrProfReader>> -IndexedInstrProfReader::create(std::string Path) { +IndexedInstrProfReader::create(const Twine &Path) {    // Set up the buffer to read.    auto BufferOrError = setupMemoryBuffer(Path);    if (Error E = BufferOrError.takeError()) diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp index d3929e81ff4..af80b036a5b 100644 --- a/llvm/lib/ProfileData/SampleProfReader.cpp +++ b/llvm/lib/ProfileData/SampleProfReader.cpp @@ -733,7 +733,7 @@ bool SampleProfileReaderGCC::hasFormat(const MemoryBuffer &Buffer) {  ///  /// \returns an error code indicating the status of the buffer.  static ErrorOr<std::unique_ptr<MemoryBuffer>> -setupMemoryBuffer(std::string Filename) { +setupMemoryBuffer(const Twine &Filename) {    auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename);    if (std::error_code EC = BufferOrErr.getError())      return EC; @@ -756,7 +756,7 @@ setupMemoryBuffer(std::string Filename) {  ///  /// \returns an error code indicating the status of the created reader.  ErrorOr<std::unique_ptr<SampleProfileReader>> -SampleProfileReader::create(StringRef Filename, LLVMContext &C) { +SampleProfileReader::create(const Twine &Filename, LLVMContext &C) {    auto BufferOrError = setupMemoryBuffer(Filename);    if (std::error_code EC = BufferOrError.getError())      return EC;  | 

