diff options
author | Jessica Paquette <jpaquette@apple.com> | 2018-08-31 20:20:54 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2018-08-31 20:20:54 +0000 |
commit | 872a4c92b24d225cd781b9def6f02aa82b8a5da5 (patch) | |
tree | 1fa576566c085dc0a60c72c7d02ee91d6c753b15 /llvm/lib/Analysis/LoopPass.cpp | |
parent | 9eda13e9762659989e1ff6874cdf970e6f779f58 (diff) | |
download | bcm5719-llvm-872a4c92b24d225cd781b9def6f02aa82b8a5da5.tar.gz bcm5719-llvm-872a4c92b24d225cd781b9def6f02aa82b8a5da5.zip |
[NFC] Pre-calculate loop IR counts in size remarks.
Another commit reducing compile time in size remarks.
Cache the size of the module and loop, and update values based
off of deltas instead. Avoid recalculating the size of the
whole module whenever possible.
3/6
llvm-svn: 341247
Diffstat (limited to 'llvm/lib/Analysis/LoopPass.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index f4f00f063a0..191d5f0f4ad 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -194,8 +194,13 @@ bool LPPassManager::runOnFunction(Function &F) { } // Walk Loops - unsigned InstrCount = 0; + unsigned InstrCount, FunctionSize = 0; bool EmitICRemark = M.shouldEmitInstrCountChangedRemark(); + // Collect the initial size of the module and the function we're looking at. + if (EmitICRemark) { + InstrCount = initSizeRemarkInfo(M); + FunctionSize = F.getInstructionCount(); + } while (!LQ.empty()) { CurrentLoopDeleted = false; CurrentLoop = LQ.back(); @@ -213,11 +218,19 @@ bool LPPassManager::runOnFunction(Function &F) { { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); TimeRegion PassTimer(getPassTimer(P)); - if (EmitICRemark) - InstrCount = initSizeRemarkInfo(M); Changed |= P->runOnLoop(CurrentLoop, *this); - if (EmitICRemark) - emitInstrCountChangedRemark(P, M, InstrCount); + if (EmitICRemark) { + unsigned NewSize = F.getInstructionCount(); + // Update the size of the function, emit a remark, and update the + // size of the module. + if (NewSize != FunctionSize) { + emitInstrCountChangedRemark(P, M, InstrCount); + int64_t Delta = static_cast<int64_t>(NewSize) - + static_cast<int64_t>(FunctionSize); + InstrCount = static_cast<int64_t>(InstrCount) + Delta; + FunctionSize = NewSize; + } + } } if (Changed) |