code cleanup -- commoning IR travsersals

llvm-svn: 282034
This commit is contained in:
Xinliang David Li 2016-09-20 22:39:47 +00:00
parent 177ccc554b
commit 9780fc1451
1 changed files with 5 additions and 3 deletions

View File

@ -314,6 +314,7 @@ private:
std::unordered_multimap<Comdat *, GlobalValue *> &ComdatMembers; std::unordered_multimap<Comdat *, GlobalValue *> &ComdatMembers;
public: public:
std::vector<Instruction *> IndirectCallSites;
SelectInstVisitor SIVisitor; SelectInstVisitor SIVisitor;
std::string FuncName; std::string FuncName;
GlobalVariable *FuncNameVar; GlobalVariable *FuncNameVar;
@ -347,6 +348,7 @@ public:
// This should be done before CFG hash computation. // This should be done before CFG hash computation.
SIVisitor.countSelects(Func); SIVisitor.countSelects(Func);
NumOfPGOSelectInsts += SIVisitor.getNumOfSelectInsts(); NumOfPGOSelectInsts += SIVisitor.getNumOfSelectInsts();
IndirectCallSites = findIndirectCallSites(Func);
FuncName = getPGOFuncName(F); FuncName = getPGOFuncName(F);
computeCFGHash(); computeCFGHash();
@ -395,7 +397,7 @@ void FuncPGOInstrumentation<Edge, BBInfo>::computeCFGHash() {
} }
JC.update(Indexes); JC.update(Indexes);
FunctionHash = (uint64_t)SIVisitor.getNumOfSelectInsts() << 56 | FunctionHash = (uint64_t)SIVisitor.getNumOfSelectInsts() << 56 |
(uint64_t)findIndirectCallSites(F).size() << 48 | (uint64_t)IndirectCallSites.size() << 48 |
(uint64_t)MST.AllEdges.size() << 32 | JC.getCRC(); (uint64_t)MST.AllEdges.size() << 32 | JC.getCRC();
} }
@ -550,7 +552,7 @@ static void instrumentOneFunc(
return; return;
unsigned NumIndirectCallSites = 0; unsigned NumIndirectCallSites = 0;
for (auto &I : findIndirectCallSites(F)) { for (auto &I : FuncInfo.IndirectCallSites) {
CallSite CS(I); CallSite CS(I);
Value *Callee = CS.getCalledValue(); Value *Callee = CS.getCalledValue();
DEBUG(dbgs() << "Instrument one indirect call: CallSite Index = " DEBUG(dbgs() << "Instrument one indirect call: CallSite Index = "
@ -1002,7 +1004,7 @@ void PGOUseFunc::annotateIndirectCallSites() {
createPGOFuncNameMetadata(F, FuncInfo.FuncName); createPGOFuncNameMetadata(F, FuncInfo.FuncName);
unsigned IndirectCallSiteIndex = 0; unsigned IndirectCallSiteIndex = 0;
auto IndirectCallSites = findIndirectCallSites(F); auto &IndirectCallSites = FuncInfo.IndirectCallSites;
unsigned NumValueSites = unsigned NumValueSites =
ProfileRecord.getNumValueSites(IPVK_IndirectCallTarget); ProfileRecord.getNumValueSites(IPVK_IndirectCallTarget);
if (NumValueSites != IndirectCallSites.size()) { if (NumValueSites != IndirectCallSites.size()) {