Optimizing compilation times of Generated Code with Templates
- Clang requirements: https://llvm.org/docs/GettingStarted.html#requirements
- Ninja build system: https://ninja-build.org/
./tools/build_deps.sh
This will download, patch, and build clang, llvm, and templight.
These patches add modifications to Clang's frontend to gather more metrics on compilation times
- Template Instatiation Time: https://reviews.llvm.org/D36946
- Preprocessing Time (Lex) (author @Brian Gesiak): https://reviews.llvm.org/D36492
- Capture template instantiations to gather data on instantiation times. Original Project: https://github.com/mikael-s-persson/templight
- Convert profiled template instantitations into a nice list showing instantitation time per template: https://github.com/eduardo-elizondo/templight-tools
If you have CMake follow: example/CMakeLists.txt
./external/llvm_build/bin/clang++ -ftime-report a.cpp
./external/llvm_build_bin/templight++ -Xtemplight -profiler -Xtemplight -ignore-system -c a.cpp./tools/get_inst_times.sh results your_build/file.cpp.o.trace.pbf
For more flags that you can use for templight, visit the github in the Requirement section. In general, "profiler" and "ignore-system" have been the most useful ones.
Please create a github issue and we can start a discussion!