diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -721,7 +721,7 @@ using BodySampleMap = std::map; // NOTE: Using a StringMap here makes parsed profiles consume around 17% more // memory, which is *very* significant for large profiles. -using FunctionSamplesMap = std::map>; +using FunctionSamplesMap = std::map>; using CallsiteSampleMap = std::map; using LocToLocMap = std::unordered_map; diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp --- a/llvm/lib/ProfileData/SampleProf.cpp +++ b/llvm/lib/ProfileData/SampleProf.cpp @@ -535,7 +535,7 @@ } else if (GenerateMergedBaseProfiles) { ProfileMap[ChildProfile->getContext()].merge(*ChildProfile); auto &SamplesMap = NodeProfile->functionSamplesAt(ChildNode.CallSiteLoc); - SamplesMap[ChildProfile->getName().str()].getContext().setAttribute( + SamplesMap[ChildProfile->getName()].getContext().setAttribute( ContextDuplicatedIntoBase); } diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp --- a/llvm/lib/ProfileData/SampleProfReader.cpp +++ b/llvm/lib/ProfileData/SampleProfReader.cpp @@ -394,7 +394,7 @@ switch (LineTy) { case LineType::CallSiteProfile: { FunctionSamples &FSamples = InlineStack.back()->functionSamplesAt( - LineLocation(LineOffset, Discriminator))[std::string(FName)]; + LineLocation(LineOffset, Discriminator))[FName]; FSamples.setName(FName); MergeResult(Result, FSamples.addTotalSamples(NumSamples)); InlineStack.push_back(&FSamples); @@ -643,7 +643,7 @@ uint32_t DiscriminatorVal = (*Discriminator) & getDiscriminatorMask(); FunctionSamples &CalleeProfile = FProfile.functionSamplesAt( - LineLocation(*LineOffset, DiscriminatorVal))[std::string(*FName)]; + LineLocation(*LineOffset, DiscriminatorVal))[*FName]; CalleeProfile.setName(*FName); if (std::error_code EC = readProfile(CalleeProfile)) return EC; @@ -1193,7 +1193,7 @@ CalleeProfile = const_cast( &FProfile->functionSamplesAt(LineLocation( *LineOffset, - *Discriminator))[std::string(FContext.get().getName())]); + *Discriminator))[FContext->getName()]); } if (std::error_code EC = readFuncMetadata(ProfileHasAttribute, CalleeProfile)) @@ -1614,7 +1614,7 @@ uint32_t LineOffset = Offset >> 16; uint32_t Discriminator = Offset & 0xffff; FProfile = &CallerProfile->functionSamplesAt( - LineLocation(LineOffset, Discriminator))[std::string(Name)]; + LineLocation(LineOffset, Discriminator))[Name]; } FProfile->setName(Name); diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp --- a/llvm/unittests/ProfileData/SampleProfTest.cpp +++ b/llvm/unittests/ProfileData/SampleProfTest.cpp @@ -157,7 +157,7 @@ // Add inline instance with name "_Z3gooi". StringRef GooName("_Z3gooi"); auto &GooSamples = - FooSamples.functionSamplesAt(LineLocation(7, 0))[GooName.str()]; + FooSamples.functionSamplesAt(LineLocation(7, 0))[GooName]; GooSamples.setName(GooName); GooSamples.addTotalSamples(502); GooSamples.addBodySamples(3, 0, 502); @@ -165,7 +165,7 @@ // Add inline instance with name "_Z3hooi". StringRef HooName("_Z3hooi"); auto &HooSamples = - GooSamples.functionSamplesAt(LineLocation(9, 0))[HooName.str()]; + GooSamples.functionSamplesAt(LineLocation(9, 0))[HooName]; HooSamples.setName(HooName); HooSamples.addTotalSamples(317); HooSamples.addBodySamples(4, 0, 317);