Skip to content

Commit

Permalink
code cleanup -- commoning IR travsersals
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282034 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
david-xl committed Sep 20, 2016
1 parent 810e009 commit 7732977
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ template <class Edge, class BBInfo> class FuncPGOInstrumentation {
std::unordered_multimap<Comdat *, GlobalValue *> &ComdatMembers;

public:
std::vector<Instruction *> IndirectCallSites;
SelectInstVisitor SIVisitor;
std::string FuncName;
GlobalVariable *FuncNameVar;
Expand Down Expand Up @@ -347,6 +348,7 @@ template <class Edge, class BBInfo> class FuncPGOInstrumentation {
// This should be done before CFG hash computation.
SIVisitor.countSelects(Func);
NumOfPGOSelectInsts += SIVisitor.getNumOfSelectInsts();
IndirectCallSites = findIndirectCallSites(Func);

FuncName = getPGOFuncName(F);
computeCFGHash();
Expand Down Expand Up @@ -395,7 +397,7 @@ void FuncPGOInstrumentation<Edge, BBInfo>::computeCFGHash() {
}
JC.update(Indexes);
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();
}

Expand Down Expand Up @@ -550,7 +552,7 @@ static void instrumentOneFunc(
return;

unsigned NumIndirectCallSites = 0;
for (auto &I : findIndirectCallSites(F)) {
for (auto &I : FuncInfo.IndirectCallSites) {
CallSite CS(I);
Value *Callee = CS.getCalledValue();
DEBUG(dbgs() << "Instrument one indirect call: CallSite Index = "
Expand Down Expand Up @@ -1002,7 +1004,7 @@ void PGOUseFunc::annotateIndirectCallSites() {
createPGOFuncNameMetadata(F, FuncInfo.FuncName);

unsigned IndirectCallSiteIndex = 0;
auto IndirectCallSites = findIndirectCallSites(F);
auto &IndirectCallSites = FuncInfo.IndirectCallSites;
unsigned NumValueSites =
ProfileRecord.getNumValueSites(IPVK_IndirectCallTarget);
if (NumValueSites != IndirectCallSites.size()) {
Expand Down

0 comments on commit 7732977

Please sign in to comment.