[llvm] r341248 - [NFC] Pre-calculate module IR counts in size remarks.
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 31 13:20:55 PDT 2018
Author: paquette
Date: Fri Aug 31 13:20:55 2018
New Revision: 341248
URL: http://llvm.org/viewvc/llvm-project?rev=341248&view=rev
Log:
[NFC] Pre-calculate module IR counts in size remarks.
Same as the previous NFC commits in the same vein.
This one introduces a TODO. I'm going to change emitInstrCountChangedRemark
so that it takes in a delta. Since the delta isn't necessary yet, it's not
there. For now, this means that we're calculating the size of the module
twice.
Just done separately to keep the patches small.
4/6
Modified:
llvm/trunk/lib/IR/LegacyPassManager.cpp
Modified: llvm/trunk/lib/IR/LegacyPassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LegacyPassManager.cpp?rev=341248&r1=341247&r2=341248&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LegacyPassManager.cpp (original)
+++ llvm/trunk/lib/IR/LegacyPassManager.cpp Fri Aug 31 13:20:55 2018
@@ -1622,8 +1622,14 @@ MPPassManager::runOnModule(Module &M) {
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
Changed |= getContainedPass(Index)->doInitialization(M);
- unsigned InstrCount = 0;
+ unsigned InstrCount, ModuleCount = 0;
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
+ // Collect the initial size of the module.
+ if (EmitICRemark) {
+ InstrCount = initSizeRemarkInfo(M);
+ ModuleCount = InstrCount;
+ }
+
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
ModulePass *MP = getContainedPass(Index);
bool LocalChanged = false;
@@ -1637,11 +1643,18 @@ MPPassManager::runOnModule(Module &M) {
PassManagerPrettyStackEntry X(MP, M);
TimeRegion PassTimer(getPassTimer(MP));
- if (EmitICRemark)
- InstrCount = initSizeRemarkInfo(M);
LocalChanged |= MP->runOnModule(M);
- if (EmitICRemark)
- emitInstrCountChangedRemark(MP, M, InstrCount);
+ if (EmitICRemark) {
+ // Update the size of the module.
+ // TODO: emitInstrCountChangedRemark should take in a delta between
+ // the old count and new count. Right now, we're calculating this
+ // twice.
+ ModuleCount = M.getInstructionCount();
+ if (ModuleCount != InstrCount) {
+ emitInstrCountChangedRemark(MP, M, InstrCount);
+ ModuleCount = InstrCount;
+ }
+ }
}
Changed |= LocalChanged;
More information about the llvm-commits
mailing list