From: Xinliang David Li Date: Sun, 3 Jan 2016 04:38:13 +0000 (+0000) Subject: [PGO] simple refactoring (NFC) X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=06205695762b777ce236cc120745a5a2c061ee0c [PGO] simple refactoring (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256695 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index d8e9174196d..6b2a396f9b1 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/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/lib/ProfileData/InstrProf.cpp b/lib/ProfileData/InstrProf.cpp index df3f8fade3b..3c752699a27 100644 --- a/lib/ProfileData/InstrProf.cpp +++ b/lib/ProfileData/InstrProf.cpp @@ -197,14 +197,18 @@ int collectPGOFuncNameStrings(const std::vector &NameStrs, return 0; } +StringRef getPGOFuncNameInitializer(GlobalVariable *NameVar) { + auto *Arr = cast(NameVar->getInitializer()); + StringRef NameStr = + Arr->isCString() ? Arr->getAsCString() : Arr->getAsString(); + return NameStr; +} + int collectPGOFuncNameStrings(const std::vector &NameVars, std::string &Result) { std::vector NameStrs; for (auto *NameVar : NameVars) { - auto *Arr = cast(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); }