diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/IR/LegacyPassManagers.h | 3 | ||||
-rw-r--r-- | llvm/lib/Analysis/CallGraphSCCPass.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/LegacyPassManager.cpp | 26 |
4 files changed, 14 insertions, 25 deletions
diff --git a/llvm/include/llvm/IR/LegacyPassManagers.h b/llvm/include/llvm/IR/LegacyPassManagers.h index c0b98dcf9eb..f7c15500212 100644 --- a/llvm/include/llvm/IR/LegacyPassManagers.h +++ b/llvm/include/llvm/IR/LegacyPassManagers.h @@ -410,7 +410,8 @@ public: /// Emit a remark signifying that the number of IR instructions in the module /// changed. - void emitInstrCountChangedRemark(Pass *P, Module &M, unsigned CountBefore); + void emitInstrCountChangedRemark(Pass *P, Module &M, int64_t Delta, + unsigned CountBefore); protected: // Top level manager. diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp index d090b5afd2e..24dbda05f4b 100644 --- a/llvm/lib/Analysis/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp @@ -124,7 +124,7 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, Module &M = CG.getModule(); if (!PM) { - CallGraphSCCPass *CGSP = (CallGraphSCCPass*)P; + CallGraphSCCPass *CGSP = (CallGraphSCCPass *)P; if (!CallGraphUpToDate) { DevirtualizedCall |= RefreshCallGraph(CurSCC, CG, false); CallGraphUpToDate = true; @@ -140,13 +140,13 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, if (EmitICRemark) { // FIXME: Add getInstructionCount to CallGraphSCC. - // TODO: emitInstrCountChangedRemark should take in the delta between - // SCCount and InstrCount. SCCCount = M.getInstructionCount(); // Is there a difference in the number of instructions in the module? if (SCCCount != InstrCount) { // Yep. Emit a remark and update InstrCount. - emitInstrCountChangedRemark(P, M, InstrCount); + int64_t Delta = + static_cast<int64_t>(SCCCount) - static_cast<int64_t>(InstrCount); + emitInstrCountChangedRemark(P, M, Delta, InstrCount); InstrCount = SCCCount; } } diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 191d5f0f4ad..f60b1815ce4 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -224,9 +224,9 @@ bool LPPassManager::runOnFunction(Function &F) { // 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); + emitInstrCountChangedRemark(P, M, Delta, InstrCount); InstrCount = static_cast<int64_t>(InstrCount) + Delta; FunctionSize = NewSize; } diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 4e1d1f5c539..3c97d337321 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -142,6 +142,7 @@ unsigned PMDataManager::initSizeRemarkInfo(Module &M) { } void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M, + int64_t Delta, unsigned CountBefore) { // We need a function containing at least one basic block in order to output // remarks. Since it's possible that the first function in the module doesn't @@ -157,25 +158,13 @@ void PMDataManager::emitInstrCountChangedRemark(Pass *P, Module &M, // We found a function containing at least one basic block. Function *F = &*It; - // How many instructions are in the module now? - unsigned CountAfter = M.getInstructionCount(); - - // If there was no change, don't emit a remark. - if (CountBefore == CountAfter) - return; - // If it's a pass manager, don't emit a remark. (This hinges on the assumption // that the only passes that return non-null with getAsPMDataManager are pass // managers.) The reason we have to do this is to avoid emitting remarks for // CGSCC passes. if (P->getAsPMDataManager()) return; - - // Compute a possibly negative delta between the instruction count before - // running P, and after running P. - int64_t Delta = - static_cast<int64_t>(CountAfter) - static_cast<int64_t>(CountBefore); - + int64_t CountAfter = static_cast<int64_t>(CountBefore) + Delta; BasicBlock &BB = *F->begin(); OptimizationRemarkAnalysis R("size-info", "IRSizeChange", DiagnosticLocation(), &BB); @@ -1315,9 +1304,9 @@ bool BBPassManager::runOnFunction(Function &F) { // 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); + emitInstrCountChangedRemark(BP, M, Delta, InstrCount); InstrCount = static_cast<int64_t>(InstrCount) + Delta; BBSize = NewSize; } @@ -1552,9 +1541,9 @@ bool FPPassManager::runOnFunction(Function &F) { // Update the size of the function, emit a remark, and update the size // of the module. if (NewSize != FunctionSize) { - emitInstrCountChangedRemark(FP, M, InstrCount); int64_t Delta = static_cast<int64_t>(NewSize) - static_cast<int64_t>(FunctionSize); + emitInstrCountChangedRemark(FP, M, Delta, InstrCount); InstrCount = static_cast<int64_t>(InstrCount) + Delta; FunctionSize = NewSize; } @@ -1646,12 +1635,11 @@ MPPassManager::runOnModule(Module &M) { LocalChanged |= MP->runOnModule(M); 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); + int64_t Delta = static_cast<int64_t>(ModuleCount) - + static_cast<int64_t>(InstrCount); + emitInstrCountChangedRemark(MP, M, Delta, InstrCount); ModuleCount = InstrCount; } } |