This is an archive of the discontinued LLVM Phabricator instance.

Output per-function size-info remarks
ClosedPublic

Authored by paquette on Aug 29 2018, 4:21 PM.

Details

Reviewers
anemet
thegameg
Summary

This patch adds per-function size information remarks. Previously, passing -Rpass-analysis=size-info would only give you per-module changes.

By adding the ability to do this per-function, it's easier to see which functions contributed the most to size changes.

(Note that we still have a random function name attached to the remark which is kind of misleading. Since we want to emit remarks for deleted functions as well, we can't use the function we're emitting the remark for in the OptimizationRemarkAnalysis. I put a FIXME in for this, but if there's a better way around it, it'd be nice to avoid the issue entirely.)

Diff Detail

Event Timeline

paquette created this revision.Aug 29 2018, 4:21 PM
thegameg accepted this revision.Aug 30 2018, 5:43 AM

Other than the comments it LGTM, thanks!

lib/IR/LegacyPassManager.cpp
175

Why not FunctionToInstrCount[F.getName().str()] = std::pair<unsigned, unsigned>(0, FnSize); as used previously in initSizeRemarkInfo?

241

You may be able to avoid using BB by calling the DiagnosticInfoIROptimization constructor directly.

This revision is now accepted and ready to land.Aug 30 2018, 5:43 AM

I ran this with a debug build, and I noticed it's pretty heavy wrt compile time. I'm working on fixing that before committing.

Also, @anemet asked me offline to provide some opt-stats output. Here's that for sqlite3 at -O2 + size remarks:

Total number of remarks 56884

Top 10 remarks by pass:

gvn                            56%
licm                           21%
inline                         15%
loop-vectorize                  4%
slp-vectorizer                  2%
prologepilog                    1%
asm-printer                     1%
regalloc                        0%
loop-unroll                     0%
tailcallelim                    0%

Top 10 remarks:

gvn/LoadClobbered              54%
licm/InstSunk                  14%
inline/Inlined                  7%
inline/TooCostly                5%
licm/LoadWithLoopInvariantAddressInvalidated  4%
licm/Hoisted                    3%
inline/NeverInline              2%
loop-vectorize/MissedDetails    1%
loop-vectorize/CFGNotUnderstood  1%
slp-vectorizer/NotPossible      1%
paquette updated this revision to Diff 163919.Sep 4 2018, 2:24 PM

Updated patch to reflect the NFC changes I put in to speed up size remarks.

@thegameg, I tried using the DiagnosticInfoIROptimization constructor directly like you suggested, but I don't think that's going to work. It's an abstract class, so it doesn't like it unfortunately. :( I'll look into it in a follow-up. I think it might be a little more invasive than expected.

paquette updated this revision to Diff 163926.Sep 4 2018, 2:40 PM
paquette marked an inline comment as done.

Forgot to address a review comment; just did that.

thegameg accepted this revision.Sep 6 2018, 11:45 AM

Still LGTM.

paquette closed this revision.Sep 6 2018, 2:21 PM

Committed in r341588.

Thanks!

https://reviews.llvm.org/rL341588