diff options
| author | Jessica Paquette <jpaquette@apple.com> | 2018-08-31 20:20:53 +0000 |
|---|---|---|
| committer | Jessica Paquette <jpaquette@apple.com> | 2018-08-31 20:20:53 +0000 |
| commit | 9eda13e9762659989e1ff6874cdf970e6f779f58 (patch) | |
| tree | 023ccaaef516a15a9802ed6a57c19af010724a40 /llvm/lib/IR | |
| parent | f2a202ce7a2594e07fd6735c2f6cf25b3a749916 (diff) | |
| download | bcm5719-llvm-9eda13e9762659989e1ff6874cdf970e6f779f58.tar.gz bcm5719-llvm-9eda13e9762659989e1ff6874cdf970e6f779f58.zip | |
[NFC] Pre-calculate basic block IR counts in size remarks.
Size remarks are slow due to lots of recalculation of the module.
This is similar to the previous commit. Cache the size of the module and
update counts in basic block passes based off a less-expensive delta.
2/6
llvm-svn: 341246
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/LegacyPassManager.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 8ce8d7df4d5..efaa66f25ff 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -1287,9 +1287,15 @@ bool BBPassManager::runOnFunction(Function &F) { bool Changed = doInitialization(F); Module &M = *F.getParent(); - unsigned InstrCount = 0; + unsigned InstrCount, BBSize = 0; bool EmitICRemark = M.shouldEmitInstrCountChangedRemark(); - for (BasicBlock &BB : F) + if (EmitICRemark) + InstrCount = initSizeRemarkInfo(M); + + for (BasicBlock &BB : F) { + // Collect the initial size of the basic block. + if (EmitICRemark) + BBSize = BB.size(); for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { BasicBlockPass *BP = getContainedPass(Index); bool LocalChanged = false; @@ -1303,11 +1309,19 @@ bool BBPassManager::runOnFunction(Function &F) { // If the pass crashes, remember this. PassManagerPrettyStackEntry X(BP, BB); TimeRegion PassTimer(getPassTimer(BP)); - if (EmitICRemark) - InstrCount = initSizeRemarkInfo(M); LocalChanged |= BP->runOnBasicBlock(BB); - if (EmitICRemark) - emitInstrCountChangedRemark(BP, M, InstrCount); + if (EmitICRemark) { + unsigned NewSize = BB.size(); + // Update the size of the basic block, emit a remark, and update the + // size of the module. + if (NewSize != BBSize) { + emitInstrCountChangedRemark(BP, M, InstrCount); + int64_t Delta = + static_cast<int64_t>(NewSize) - static_cast<int64_t>(BBSize); + InstrCount = static_cast<int64_t>(InstrCount) + Delta; + BBSize = NewSize; + } + } } Changed |= LocalChanged; @@ -1322,6 +1336,7 @@ bool BBPassManager::runOnFunction(Function &F) { recordAvailableAnalysis(BP); removeDeadPasses(BP, BB.getName(), ON_BASICBLOCK_MSG); } + } return doFinalization(F) || Changed; } |

