From 773297799530b0539a70baa1e12d0a58d4bb08fc Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Tue, 20 Sep 2016 22:39:47 +0000 Subject: [PATCH] code cleanup -- commoning IR travsersals git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282034 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 4f333d618103..615d9edf3e4a 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -314,6 +314,7 @@ template class FuncPGOInstrumentation { std::unordered_multimap &ComdatMembers; public: + std::vector IndirectCallSites; SelectInstVisitor SIVisitor; std::string FuncName; GlobalVariable *FuncNameVar; @@ -347,6 +348,7 @@ template class FuncPGOInstrumentation { // This should be done before CFG hash computation. SIVisitor.countSelects(Func); NumOfPGOSelectInsts += SIVisitor.getNumOfSelectInsts(); + IndirectCallSites = findIndirectCallSites(Func); FuncName = getPGOFuncName(F); computeCFGHash(); @@ -395,7 +397,7 @@ void FuncPGOInstrumentation::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(); } @@ -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 = " @@ -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()) {