diff options
author | Jessica Paquette <jpaquette@apple.com> | 2018-05-18 17:26:39 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2018-05-18 17:26:39 +0000 |
commit | e49374d00995e2917c553933de89137686f172d6 (patch) | |
tree | 6fe53a211d6c1142f124772b607136a42ece1072 /llvm/lib/Analysis/CallGraphSCCPass.cpp | |
parent | b809fc3d63a26b6ed9baf5bc6b84edbd02e59b68 (diff) | |
download | bcm5719-llvm-e49374d00995e2917c553933de89137686f172d6.tar.gz bcm5719-llvm-e49374d00995e2917c553933de89137686f172d6.zip |
Add remarks describing when a pass changes the IR instruction count of a module
This patch adds a remark which tells the user when a pass changes the number of
IR instructions in a module.
It can be enabled by using -Rpass-analysis=size-info.
The point of this is to make it easier to collect statistics on how passes
modify programs in terms of code size. This is similar in concept to timing
reports, but using a remark-based interface makes it easy to diff changes over
multiple compilations of the same program.
By adding functionality like this, we can see
* Which passes impact code size the most
* How passes impact code size at different optimization levels
* Which pass might have contributed the most to an overall code size
regression
The patch lives in the legacy pass manager, but since it's simply emitting
remarks, it shouldn't be too difficult to adapt the functionality to the new
pass manager as well. This can also be adapted to handle MachineInstr counts in
code gen passes.
https://reviews.llvm.org/D38768
llvm-svn: 332739
Diffstat (limited to 'llvm/lib/Analysis/CallGraphSCCPass.cpp')
-rw-r--r-- | llvm/lib/Analysis/CallGraphSCCPass.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp index 4bb181e352d..ef61c65463f 100644 --- a/llvm/lib/Analysis/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp @@ -120,6 +120,7 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, bool &DevirtualizedCall) { bool Changed = false; PMDataManager *PM = P->getAsPMDataManager(); + Module &M = CG.getModule(); if (!PM) { CallGraphSCCPass *CGSP = (CallGraphSCCPass*)P; @@ -130,7 +131,12 @@ bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC, { TimeRegion PassTimer(getPassTimer(CGSP)); + unsigned InstrCount = initSizeRemarkInfo(M); Changed = CGSP->runOnSCC(CurSCC); + + // If the pass modified the module, it may have modified the instruction + // count of the module. Try emitting a remark. + emitInstrCountChangedRemark(P, M, InstrCount); } // After the CGSCCPass is done, when assertions are enabled, use |