This is an archive of the discontinued LLVM Phabricator instance.

Sink all InitializePasses.h includes
ClosedPublic

Authored by rnk on Nov 13 2019, 3:08 PM.

Details

Summary

This file lists every pass in LLVM, and is included by Pass.h, which is
very popular. Every time we add, remove, or rename a pass in LLVM, it
caused lots of recompilation.

I found this fact by looking at this table, which is sorted by the
number of times a file was changed over the last 100,000 git commits
multiplied by the number of object files that depend on it in the
current checkout:

recompiles    touches affected_files  header
342380        95      3604    llvm/include/llvm/ADT/STLExtras.h
314730        234     1345    llvm/include/llvm/InitializePasses.h
307036        118     2602    llvm/include/llvm/ADT/APInt.h
213049        59      3611    llvm/include/llvm/Support/MathExtras.h
170422        47      3626    llvm/include/llvm/Support/Compiler.h
162225        45      3605    llvm/include/llvm/ADT/Optional.h
158319        63      2513    llvm/include/llvm/ADT/Triple.h
140322        39      3598    llvm/include/llvm/ADT/StringRef.h
137647        59      2333    llvm/include/llvm/Support/Error.h
131619        73      1803    llvm/include/llvm/Support/FileSystem.h

Before this change, touching InitializePasses.h would cause 1345 files
to recompile. After this change, touching it only causes 550 compiles in
an incremental rebuild.

Diff Detail

Event Timeline

rnk created this revision.Nov 13 2019, 3:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert resigned from this revision.Nov 13 2019, 4:08 PM

FWIW, I'm always in favor of changes like these to cut compile time.

asbirlea accepted this revision.Nov 13 2019, 4:21 PM

This looks like a great improvement, IMO.

This revision is now accepted and ready to land.Nov 13 2019, 4:21 PM

Nice! What does the recompiles column mean?

This revision was automatically updated to reflect the committed changes.
rnk added a comment.Nov 13 2019, 4:43 PM

Nice! What does the recompiles column mean?

It's just touches * affected_files, mainly so I can send it to sort -r -n.

dmgreen added inline comments.
llvm/lib/CodeGen/PostRAHazardRecognizer.cpp
1

Was this intentional? I happened to randomly open this file.

rnk added a comment.Nov 14 2019, 9:34 AM

So, apparently this broke almost every buildbot because gtest binaries are not included in the all target, which I built on Linux and Windows before I pushed and then had to run off for the day. Thanks to @aheejin for fixing the build. In the future, please don't wait for review if the build is broken. A revert would've been appropriate and wouldn't need review, and a point fixes don't really need review. In any case, things seem to be stable this morning. Sorry for the disturbance!

rnk marked an inline comment as done.Nov 14 2019, 11:56 AM
rnk added inline comments.
llvm/lib/CodeGen/PostRAHazardRecognizer.cpp
1

Thanks for catching that. I fixed it in rG5fe3f00ae2753d84ad2f9ca7c5a2b56c34344dfb. I used diffgrep to filter out all the hunks of #include changes and reviewed the rest and found one other formatting oddity.