diff options
author | Xinliang David Li <davidxl@google.com> | 2016-01-03 04:38:13 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-01-03 04:38:13 +0000 |
commit | 37c1fa047d7e043bb789bea533d841a95b97da78 (patch) | |
tree | 1887aa1727a71bb5f709c34ce799faa8412f02e6 | |
parent | ded575e4ebfdea357c02d22f9f255d6e20eb0c3c (diff) | |
download | bcm5719-llvm-37c1fa047d7e043bb789bea533d841a95b97da78.tar.gz bcm5719-llvm-37c1fa047d7e043bb789bea533d841a95b97da78.zip |
[PGO] simple refactoring (NFC)
llvm-svn: 256695
-rw-r--r-- | llvm/include/llvm/ProfileData/InstrProf.h | 2 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index d8e9174196d..6b2a396f9b1 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -155,6 +155,8 @@ GlobalVariable *createPGOFuncNameVar(Function &F, StringRef FuncName); GlobalVariable *createPGOFuncNameVar(Module &M, GlobalValue::LinkageTypes Linkage, StringRef FuncName); +/// Return the initializer in string of the PGO name var \c NameVar. +StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar); /// Given a PGO function name, remove the filename prefix and return /// the original (static) function name. diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index df3f8fade3b..3c752699a27 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -197,14 +197,18 @@ int collectPGOFuncNameStrings(const std::vector<std::string> &NameStrs, return 0; } +StringRef getPGOFuncNameInitializer(GlobalVariable *NameVar) { + auto *Arr = cast<ConstantDataArray>(NameVar->getInitializer()); + StringRef NameStr = + Arr->isCString() ? Arr->getAsCString() : Arr->getAsString(); + return NameStr; +} + int collectPGOFuncNameStrings(const std::vector<GlobalVariable *> &NameVars, std::string &Result) { std::vector<std::string> NameStrs; for (auto *NameVar : NameVars) { - auto *Arr = cast<ConstantDataArray>(NameVar->getInitializer()); - StringRef NameStr = - Arr->isCString() ? Arr->getAsCString() : Arr->getAsString(); - NameStrs.push_back(NameStr.str()); + NameStrs.push_back(getPGOFuncNameInitializer(NameVar)); } return collectPGOFuncNameStrings(NameStrs, zlib::isAvailable(), Result); } |