[llvm] r256695 - [PGO] simple refactoring (NFC)
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 2 20:38:15 PST 2016
Author: davidxl
Date: Sat Jan 2 22:38:13 2016
New Revision: 256695
URL: http://llvm.org/viewvc/llvm-project?rev=256695&view=rev
Log:
[PGO] simple refactoring (NFC)
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/lib/ProfileData/InstrProf.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=256695&r1=256694&r2=256695&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Sat Jan 2 22:38:13 2016
@@ -155,6 +155,8 @@ GlobalVariable *createPGOFuncNameVar(Fun
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.
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=256695&r1=256694&r2=256695&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Sat Jan 2 22:38:13 2016
@@ -197,14 +197,18 @@ int collectPGOFuncNameStrings(const std:
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);
}
More information about the llvm-commits
mailing list