diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index c2e42177661..833a8d8536f 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -642,7 +642,7 @@ public: BranchProbabilityInfo *BPI = nullptr, BlockFrequencyInfo *BFI = nullptr) : F(Func), M(Modu), FuncInfo(Func, ComdatMembers, false, BPI, BFI), - FreqAttr(FFA_Normal) {} + CountPosition(0), ProfileCountSize(0), FreqAttr(FFA_Normal) {} // Read counts for the instrumented BB from profile. bool readCounters(IndexedInstrProfReader *PGOReader); @@ -682,6 +682,12 @@ private: // compilation. uint64_t ProgramMaxCount; + // Position of counter that remains to be read. + uint32_t CountPosition; + + // Total size of the profile count for this function. + uint32_t ProfileCountSize; + // ProfileRecord for this function. InstrProfRecord ProfileRecord; @@ -750,9 +756,8 @@ void PGOUseFunc::setInstrumentedCounts( NewEdge1.InMST = true; getBBInfo(InstrBB).setBBInfoCount(CountValue); } - // Now annotate select instructions - FuncInfo.SIVisitor.annotateSelects(F, this, &I); - assert(I == CountFromProfile.size()); + ProfileCountSize = CountFromProfile.size(); + CountPosition = I; } // Set the count value for the unknown edge. There should be one and only one @@ -892,6 +897,10 @@ void PGOUseFunc::populateCounters() { FuncMaxCount = std::max(FuncMaxCount, getBBInfo(&BB).CountValue); markFunctionAttributes(FuncEntryCount, FuncMaxCount); + // Now annotate select instructions + FuncInfo.SIVisitor.annotateSelects(F, this, &CountPosition); + assert(CountPosition == ProfileCountSize); + DEBUG(FuncInfo.dumpInfo("after reading profile.")); } |