diff options
Diffstat (limited to 'lib/Analysis/LoopPass.cpp')
-rw-r--r-- | lib/Analysis/LoopPass.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index 07a151ce0fce..a68f114b83a0 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -20,6 +20,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/OptBisect.h" #include "llvm/IR/PassManager.h" +#include "llvm/IR/PassTimingInfo.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" @@ -193,8 +194,14 @@ bool LPPassManager::runOnFunction(Function &F) { } // Walk Loops - unsigned InstrCount = 0; + unsigned InstrCount, FunctionSize = 0; + StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount; bool EmitICRemark = M.shouldEmitInstrCountChangedRemark(); + // Collect the initial size of the module and the function we're looking at. + if (EmitICRemark) { + InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount); + FunctionSize = F.getInstructionCount(); + } while (!LQ.empty()) { CurrentLoopDeleted = false; CurrentLoop = LQ.back(); @@ -209,17 +216,28 @@ bool LPPassManager::runOnFunction(Function &F) { initializeAnalysisImpl(P); + bool LocalChanged = false; { 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); + LocalChanged = P->runOnLoop(CurrentLoop, *this); + Changed |= LocalChanged; + 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) { + int64_t Delta = static_cast<int64_t>(NewSize) - + static_cast<int64_t>(FunctionSize); + emitInstrCountChangedRemark(P, M, Delta, InstrCount, + FunctionToInstrCount, &F); + InstrCount = static_cast<int64_t>(InstrCount) + Delta; + FunctionSize = NewSize; + } + } } - if (Changed) + if (LocalChanged) dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG, CurrentLoopDeleted ? "<deleted loop>" : CurrentLoop->getName()); |