diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-02-09 05:12:44 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-02-09 05:12:44 +0000 |
commit | 833571ecb42c183df2c3eec7f0957d97081659e0 (patch) | |
tree | 3bef55e26f39ecb70c7af26ce0de6306351303ef /llvm/lib | |
parent | e5fa25a094f040353891a953d0b35a89d75e5cb8 (diff) | |
download | bcm5719-llvm-833571ecb42c183df2c3eec7f0957d97081659e0.tar.gz bcm5719-llvm-833571ecb42c183df2c3eec7f0957d97081659e0.zip |
Refactor PGO function naming and MD5 hashing support out of ProfileData
Summary:
Move the function renaming logic into the Function class, and the
MD5Hash routine into the MD5 header.
This will enable these routines to be shared with ThinLTO, which
will be changed to store the MD5 hash instead of full function name
in the combined index for significant size reductions. And using the same
function naming for locals in the function index facilitates future
integration with indirect call value profiles.
Reviewers: davidxl
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D17006
llvm-svn: 260197
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 20 |
2 files changed, 25 insertions, 19 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 40a8ec61ca2..da1ddedc3dd 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -997,3 +997,27 @@ Optional<uint64_t> Function::getEntryCount() const { } return None; } + +std::string Function::getGlobalIdentifier(StringRef FuncName, + GlobalValue::LinkageTypes Linkage, + StringRef FileName) { + + // Function names may be prefixed with a binary '1' to indicate + // that the backend should not modify the symbols due to any platform + // naming convention. Do not include that '1' in the PGO profile name. + if (FuncName[0] == '\1') + FuncName = FuncName.substr(1); + + std::string NewFuncName = FuncName; + if (llvm::GlobalValue::isLocalLinkage(Linkage)) { + // For local symbols, prepend the main file name to distinguish them. + // Do not include the full path in the file name since there's no guarantee + // that it will stay the same, e.g., if the files are checked out from + // version control in different locations. + if (FileName.empty()) + NewFuncName = NewFuncName.insert(0, "<unknown>:"); + else + NewFuncName = NewFuncName.insert(0, FileName.str() + ":"); + } + return NewFuncName; +} diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 1cfc21e493a..551c414cff6 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -80,25 +80,7 @@ std::string getPGOFuncName(StringRef RawFuncName, GlobalValue::LinkageTypes Linkage, StringRef FileName, uint64_t Version LLVM_ATTRIBUTE_UNUSED) { - - // Function names may be prefixed with a binary '1' to indicate - // that the backend should not modify the symbols due to any platform - // naming convention. Do not include that '1' in the PGO profile name. - if (RawFuncName[0] == '\1') - RawFuncName = RawFuncName.substr(1); - - std::string FuncName = RawFuncName; - if (llvm::GlobalValue::isLocalLinkage(Linkage)) { - // For local symbols, prepend the main file name to distinguish them. - // Do not include the full path in the file name since there's no guarantee - // that it will stay the same, e.g., if the files are checked out from - // version control in different locations. - if (FileName.empty()) - FuncName = FuncName.insert(0, "<unknown>:"); - else - FuncName = FuncName.insert(0, FileName.str() + ":"); - } - return FuncName; + return Function::getGlobalIdentifier(RawFuncName, Linkage, FileName); } std::string getPGOFuncName(const Function &F, uint64_t Version) { |