[llvm] r341604 - Fix SampleProf code on LLP64 platforms with stoull
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 6 16:35:58 PDT 2018
Author: rnk
Date: Thu Sep 6 16:35:58 2018
New Revision: 341604
URL: http://llvm.org/viewvc/llvm-project?rev=341604&view=rev
Log:
Fix SampleProf code on LLP64 platforms with stoull
Otherwise, stoul will throw an out of range exception if the integer
doesn't fit in a 32-bit number.
Modified:
llvm/trunk/include/llvm/ProfileData/SampleProf.h
Modified: llvm/trunk/include/llvm/ProfileData/SampleProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProf.h?rev=341604&r1=341603&r2=341604&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/SampleProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/SampleProf.h Thu Sep 6 16:35:58 2018
@@ -403,7 +403,7 @@ public:
void setName(StringRef FunctionName) { Name = FunctionName; }
/// Return the function name.
- const StringRef &getName() const { return Name; }
+ StringRef getName() const { return Name; }
/// Return the original function name if it exists in Module \p M.
StringRef getFuncNameInModule(const Module *M) const {
@@ -422,7 +422,7 @@ public:
// Expect CurrentModule to be initialized by GUIDToFuncNameMapper.
if (M != CurrentModule)
llvm_unreachable("Input Module should be the same as CurrentModule");
- auto iter = GUIDToFuncNameMap.find(std::stoul(Name.data()));
+ auto iter = GUIDToFuncNameMap.find(std::stoull(Name.data()));
if (iter == GUIDToFuncNameMap.end())
return StringRef();
return iter->second;
@@ -486,8 +486,10 @@ public:
// Assume the input \p Name is a name coming from FunctionSamples itself.
// If the format is SPF_Compact_Binary, the name is already a GUID and we
// don't want to return the GUID of GUID.
- static uint64_t getGUID(const StringRef &Name) {
- return (Format == SPF_Compact_Binary) ? std::stoul(Name.data())
+ static uint64_t getGUID(StringRef Name) {
+ if (Format == SPF_Compact_Binary)
+ errs() << Name << '\n';
+ return (Format == SPF_Compact_Binary) ? std::stoull(Name.data())
: Function::getGUID(Name);
}
More information about the llvm-commits
mailing list