[PATCH] D41297: [ThinLTO] Implement summary visualizer
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 09:15:45 PST 2017
evgeny777 created this revision.
evgeny777 added reviewers: tejohnson, mehdi_amini, pcc.
Herald added a subscriber: inglorion.
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**:
F5686264: summary.png <https://reviews.llvm.org/F5686264>
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
https://reviews.llvm.org/D41297
Files:
include/llvm/IR/ModuleSummaryIndex.h
lib/IR/ModuleSummaryIndex.cpp
lib/LTO/LTOBackend.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41297.127143.patch
Type: text/x-patch
Size: 7985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171215/0bc0efae/attachment.bin>
More information about the llvm-commits
mailing list