diff options
| author | Reid Kleckner <rnk@google.com> | 2018-09-06 23:35:58 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2018-09-06 23:35:58 +0000 |
| commit | 8c4db5da5fe4ec63c9968adfe4965c41ff16a8bf (patch) | |
| tree | 364128130749867ade32c597f715f3c5880a2c22 /llvm | |
| parent | d0d0cb38bebefd3804cd66c3f65cce019fb83979 (diff) | |
| download | bcm5719-llvm-8c4db5da5fe4ec63c9968adfe4965c41ff16a8bf.tar.gz bcm5719-llvm-8c4db5da5fe4ec63c9968adfe4965c41ff16a8bf.zip | |
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.
llvm-svn: 341604
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/ProfileData/SampleProf.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h index f5e123f3c5c..65fa8a8ef0e 100644 --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -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); } |

