[PATCH] D41915: [lldCOFF] Print detailed timing information with /VERBOSE

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 17:24:41 PST 2018


zturner updated this revision to Diff 129375.
zturner added a comment.
Herald added a subscriber: mgorny.

I went to start implementing peter's suggestion, and things started getting a little interesting.  A lot of the things you might want to time are behind command line options, and it would be nice if we didn't show anything when the lines weren't relevant.

At the same time, I don't like writing code and then having someone re-invent the same thing later that is slightly different.  So although nobody's using this now, I wanted to do this in a way that could benefit, for example, the ELF linker or the MachO linker at some point in the future.

So I tried to generalize this a little bit.  Everything is moved into Common now, and the only thing defined in COFF is a set of enums that represent the various statistics that you might want to time.  You can add phases dynamically (for example, only if an option is set on the command line), and all the printing logic is raised up into common too, and it does all the work of figuring out the right set of statistics you're timing, calculating percentages, etc, so nobody else has to deal with the formatting and alignment again.

just to illustrate what I mean, currently when I link with /OPT:REF + /OPT:ICF + /DEBUG I get this:

    Input File Reading:        (  3.54%)   576 ms
    ICF:                       (  0.66%)   107 ms
    GC:                        (  1.34%)   218 ms
    Code Layout:               (  0.79%)   128 ms
    Commit Output File:        (  0.07%)    11 ms
    PDB Emission (Cumulative): ( 93.46%) 15214 ms
      Globals Stream Layout:   (  1.09%)   177 ms
      TPI Stream Layout:       (  6.71%)  1093 ms
      Type Merging:            ( 35.43%)  5767 ms
      Symbol Merging:          ( 24.43%)  3977 ms
      Commit to Disk:          ( 17.90%)  2913 ms
  ------------------------------------------------
  Total Link Time:             (100.00%) 16278 ms

whereas if I link with only /OPT:ICF and /OPT:REF but remove /DEBUG I get this:

    Input File Reading: ( 54.80%) 542 ms
    ICF:                ( 11.93%) 118 ms
    GC:                 ( 16.38%) 162 ms
    Code Layout:        ( 13.14%) 130 ms
    Commit Output File: (  1.31%)  13 ms
  ---------------------------------------
  Total Link Time:      (100.00%) 989 ms

I think this is a more friendly output and more useful from a usability perspective.  But if I went a little overboard let me know :)


https://reviews.llvm.org/D41915

Files:
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/ICF.cpp
  lld/COFF/MarkLive.cpp
  lld/COFF/Options.td
  lld/COFF/PDB.cpp
  lld/COFF/PDB.h
  lld/COFF/Timing.h
  lld/COFF/Writer.cpp
  lld/COFF/Writer.h
  lld/Common/CMakeLists.txt
  lld/Common/LinkTimer.cpp
  lld/include/lld/Common/LinkTimer.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41915.129375.patch
Type: text/x-patch
Size: 20351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180111/2916172a/attachment.bin>


More information about the llvm-commits mailing list