I find it useful on some occasions (especially when PGO is also used) to have ThinLTO combined summary exported to DOT file,
so it can be examined with GraphViz or (for large projects) analyzed with python scripts. For instance below is the graph, demonstrating
indirect call promotion of functions called cold and hot:
It shows cold and hot edges, refs (dashed lines), dead nodes (red) and is clustered by TU. This graph was obtained from following source file
(compiled with -O2 -fprofile-generate -flto=thin):
#include <stdio.h> #include <math.h> #include <stdlib.h> double H = 0, C = 0; void hot() __attribute__((noinline)) { H += (sin(H)*cos(H) + 1); } void cold() __attribute__((noinline)) { C += 2*cos(C); } void call_some(void (*fun)(), unsigned count) { fun(); } int main(int argc, char *argv[]) { // Both cold and hot are called indirectly void (*func[])() = { hot, cold }; for (int i = 0; i < atoi(argv[1]); ++i) { int d = rand() % 10; func[d > 7](); } printf("H = %f, C = %f\n", H, C); return (int)(C + H); }
The dot file is dumped when caller provides --save-temps flag and contains node GUIDs. There is a small python script (approx 10 lines) used for annotation.
The code itself is a bit messed up and lacks test case, but for now I'm just wondering if it is of any interest to anybody