Whilst investigating a missed optimization and poring over numerous
dumpfiles I found it awkward to go from dumpfile to the related pass.

For example, given dumpfiles:
  foo.c.038t.cddce1
  foo.c.079t.fre2
where are the corresponding passes implemented?

Assuming my level of GCC expertise or less, the answer appears to be to
grep for '"cddce"' and '"fre"' in the gcc source tree, which rapidly
becomes a pain when doing it for many dumps.

The following patch kit adds source-location metadata to GCC's
struct pass_data, identifying the classname of the pass, and the
__FILE__ and __LINE__ information of the pass_data, which ought to
be a good hint as to where the pass is itself implemented.

This metadata can be used internally (e.g. by plugins that are
visualizing GCC's passes), and is added to the dumpfiles, so that in
the examples above, foo.c.038t.cddce1 gains:

 ; start of dump from pass_cd_dce (../../src/gcc/tree-ssa-dce.c:1754)

 (...dump goes here...)

 ; end of dump from pass_cd_dce (../../src/gcc/tree-ssa-dce.c:1754)

and foo.c.079t.fre2 gains:

 ; start of dump from pass_fre (../../src/gcc/tree-ssa-pre.c:4933)

 (...dump goes here...)

 ; end of dump from pass_fre (../../src/gcc/tree-ssa-pre.c:4933)

identifying clearly where to look next.

Successfully bootstrapped&regrtested on x86_64-unknown-linux-gnu

OK for trunk?

David Malcolm (4):
  Add classname/filename/line metadata to struct pass_data
  Autogenerated patch to use PASS_DATA_INIT
  Manual fixes for PASS_DATA_INIT missed by the script
  Print pass metadata at the start and end of dumpfiles

 gcc/asan.c                                    | 12 ++---
 gcc/auto-inc-dec.c                            |  6 +--
 gcc/auto-profile.c                            |  5 ++-
 gcc/bb-reorder.c                              | 18 ++++----
 gcc/bt-load.c                                 | 12 ++---
 gcc/cfgcleanup.c                              | 12 ++---
 gcc/cfgexpand.c                               |  6 +--
 gcc/cfgrtl.c                                  | 18 ++++----
 gcc/cgraphbuild.c                             | 18 ++++----
 gcc/combine-stack-adj.c                       |  6 +--
 gcc/combine.c                                 |  6 +--
 gcc/common.opt                                |  4 ++
 gcc/compare-elim.c                            |  6 +--
 gcc/config/alpha/alpha.c                      | 12 ++---
 gcc/config/arc/arc.c                          | 12 ++---
 gcc/config/epiphany/mode-switch-use.c         |  6 +--
 gcc/config/epiphany/resolve-sw-modes.c        |  6 +--
 gcc/config/i386/i386.c                        |  6 +--
 gcc/config/mips/mips.c                        |  6 +--
 gcc/config/s390/s390.c                        |  6 +--
 gcc/config/sparc/sparc.c                      |  6 +--
 gcc/config/visium/visium.c                    |  6 +--
 gcc/cprop.c                                   |  6 +--
 gcc/cse.c                                     | 18 ++++----
 gcc/dce.c                                     | 12 ++---
 gcc/df-core.c                                 | 18 ++++----
 gcc/doc/invoke.texi                           | 21 +++++++++
 gcc/dse.c                                     | 12 ++---
 gcc/dwarf2cfi.c                               |  6 +--
 gcc/except.c                                  | 12 ++---
 gcc/final.c                                   | 24 +++++-----
 gcc/function.c                                | 24 +++++-----
 gcc/fwprop.c                                  | 12 ++---
 gcc/gcse.c                                    | 12 ++---
 gcc/gimple-low.c                              |  6 +--
 gcc/gimple-ssa-isolate-paths.c                |  6 +--
 gcc/gimple-ssa-strength-reduction.c           |  6 +--
 gcc/graphite.c                                | 12 ++---
 gcc/ifcvt.c                                   | 18 ++++----
 gcc/init-regs.c                               |  6 +--
 gcc/ipa-chkp.c                                | 24 +++++-----
 gcc/ipa-comdats.c                             |  6 +--
 gcc/ipa-cp.c                                  |  6 +--
 gcc/ipa-devirt.c                              |  6 +--
 gcc/ipa-icf.c                                 |  7 +--
 gcc/ipa-inline-analysis.c                     |  6 +--
 gcc/ipa-inline.c                              | 12 ++---
 gcc/ipa-profile.c                             |  6 +--
 gcc/ipa-pure-const.c                          | 24 +++++-----
 gcc/ipa-reference.c                           |  6 +--
 gcc/ipa-split.c                               | 12 ++---
 gcc/ipa-visibility.c                          | 12 ++---
 gcc/ipa.c                                     | 18 ++++----
 gcc/ira.c                                     | 12 ++---
 gcc/jump.c                                    |  6 +--
 gcc/loop-init.c                               | 36 +++++++--------
 gcc/lower-subreg.c                            | 12 ++---
 gcc/mode-switching.c                          |  6 +--
 gcc/modulo-sched.c                            |  6 +--
 gcc/omp-low.c                                 | 30 ++++++-------
 gcc/passes.c                                  | 63 +++++++++++++++------------
 gcc/postreload-gcse.c                         |  6 +--
 gcc/postreload.c                              |  6 +--
 gcc/predict.c                                 | 12 ++---
 gcc/recog.c                                   | 36 +++++++--------
 gcc/ree.c                                     |  6 +--
 gcc/reg-stack.c                               | 12 ++---
 gcc/regcprop.c                                |  6 +--
 gcc/reginfo.c                                 |  6 +--
 gcc/regrename.c                               |  6 +--
 gcc/reorg.c                                   | 12 ++---
 gcc/sanopt.c                                  |  6 +--
 gcc/sched-rgn.c                               | 24 +++++-----
 gcc/stack-ptr-mod.c                           |  6 +--
 gcc/store-motion.c                            |  6 +--
 gcc/testsuite/g++.dg/plugin/dumb_plugin.c     |  6 +--
 gcc/testsuite/g++.dg/plugin/selfassign.c      |  6 +--
 gcc/testsuite/gcc.dg/plugin/one_time_plugin.c |  6 +--
 gcc/testsuite/gcc.dg/plugin/selfassign.c      |  6 +--
 gcc/testsuite/lib/gcc-dg.exp                  | 18 ++++++++
 gcc/tracer.c                                  |  6 +--
 gcc/trans-mem.c                               | 42 +++++++++---------
 gcc/tree-call-cdce.c                          |  6 +--
 gcc/tree-cfg.c                                | 30 ++++++-------
 gcc/tree-cfgcleanup.c                         | 12 ++---
 gcc/tree-chkp-opt.c                           |  8 ++--
 gcc/tree-chkp.c                               |  8 ++--
 gcc/tree-complex.c                            | 12 ++---
 gcc/tree-eh.c                                 | 30 ++++++-------
 gcc/tree-emutls.c                             |  6 +--
 gcc/tree-if-conv.c                            |  6 +--
 gcc/tree-into-ssa.c                           |  6 +--
 gcc/tree-loop-distribution.c                  |  6 +--
 gcc/tree-nrv.c                                | 12 ++---
 gcc/tree-object-size.c                        |  6 +--
 gcc/tree-parloops.c                           |  6 +--
 gcc/tree-pass.h                               | 27 ++++++++++++
 gcc/tree-predcom.c                            |  6 +--
 gcc/tree-profile.c                            |  6 +--
 gcc/tree-sra.c                                | 18 ++++----
 gcc/tree-ssa-ccp.c                            | 12 ++---
 gcc/tree-ssa-copy.c                           |  6 +--
 gcc/tree-ssa-copyrename.c                     |  6 +--
 gcc/tree-ssa-dce.c                            | 12 ++---
 gcc/tree-ssa-dom.c                            | 12 ++---
 gcc/tree-ssa-dse.c                            |  6 +--
 gcc/tree-ssa-forwprop.c                       |  6 +--
 gcc/tree-ssa-ifcombine.c                      |  6 +--
 gcc/tree-ssa-loop-ch.c                        |  6 +--
 gcc/tree-ssa-loop-im.c                        |  6 +--
 gcc/tree-ssa-loop-ivcanon.c                   | 18 ++++----
 gcc/tree-ssa-loop-prefetch.c                  |  6 +--
 gcc/tree-ssa-loop-unswitch.c                  |  6 +--
 gcc/tree-ssa-loop.c                           | 60 ++++++++++++-------------
 gcc/tree-ssa-math-opts.c                      | 24 +++++-----
 gcc/tree-ssa-phiopt.c                         | 12 ++---
 gcc/tree-ssa-phiprop.c                        |  6 +--
 gcc/tree-ssa-pre.c                            | 12 ++---
 gcc/tree-ssa-reassoc.c                        |  6 +--
 gcc/tree-ssa-sink.c                           |  6 +--
 gcc/tree-ssa-strlen.c                         |  6 +--
 gcc/tree-ssa-structalias.c                    | 18 ++++----
 gcc/tree-ssa-uncprop.c                        |  6 +--
 gcc/tree-ssa-uninit.c                         | 12 ++---
 gcc/tree-ssa.c                                | 12 ++---
 gcc/tree-ssanames.c                           |  6 +--
 gcc/tree-stdarg.c                             | 12 ++---
 gcc/tree-switch-conversion.c                  |  6 +--
 gcc/tree-tailcall.c                           | 12 ++---
 gcc/tree-vect-generic.c                       | 12 ++---
 gcc/tree-vectorizer.c                         | 18 ++++----
 gcc/tree-vrp.c                                |  6 +--
 gcc/tree.c                                    |  6 +--
 gcc/tsan.c                                    | 12 ++---
 gcc/ubsan.c                                   |  6 +--
 gcc/var-tracking.c                            |  6 +--
 gcc/vtable-verify.c                           |  6 +--
 gcc/web.c                                     |  6 +--
 138 files changed, 838 insertions(+), 757 deletions(-)

-- 
1.8.5.3

Reply via email to