Hi,
Recently I’ve done some experiments on the LLVM/Clang code and discovered that many of our source files often include unnecessary header files. I wrote a simple tool that eliminates redundant includes and estimates benefits of doing it, and the results were quite nice: for some files we were able to save 90% of compile time! I think we want to apply some of the cleanups I found, but I’m not sure how to better do it: the total patches are 8k lines of code for LLVM and 3k lines of code for clang (I’ll attach them for reference). My suggestion would be that people take a look at the list of changed files and pick the changes for the piece of code they are working on if the changes look sane (the changes do need some checking before committing). Does it sound like a good idea? I’d appreciate any feedback on what can we do here.
The list of files for which removing redundant headers improved compile time (the numbers are compile time in seconds for a Debug build):
LLVM top 10
Filename Old New Delta
lib/CodeGen/GlobalISel/GlobalISel.cpp 0.26 0.02 -91.9%
lib/MC/MCLabel.cpp 0.19 0.02 -88.2%
tools/llvm-readobj/ObjDumper.cpp 0.43 0.10 -76.5%
lib/MC/MCWinEH.cpp 0.51 0.13 -74.3%
lib/Transforms/Vectorize/Vectorize.cpp 0.72 0.29 -59.7%
tools/llvm-diff/DiffLog.cpp 0.58 0.26 -54.6%
lib/Target/ARM/MCTargetDesc/ARMMachORelocationInfo.cpp 0.46 0.26 -44.1%
lib/DebugInfo/DWARF/DWARFExpression.cpp 0.68 0.38 -43.3%
lib/LTO/LTOModule.cpp 2.25 1.33 -41.1%
lib/Target/TargetMachine.cpp 1.76 1.10 -37.8%
Full list:
llvm.txt (25 KB)
clang.txt (10.3 KB)
llvm_redundant_headers.patch (287 KB)
clang_redundant_headers.patch (114 KB)