Consider this example:
$ cat a.cpp
void foo();
void bar();
int main() {
foo();
bar();
return 0;
}
$ cat foo.cpp
void foo(){}
$ cat bar.cpp
void bar(){}
$ clang -fprofile-instr-generate -Wl,--build-id -O2 -fpic foo.cpp -o foo.so
$ clang -fprofile-instr-generate -Wl,--build-id -O2 -fpic bar.cpp -o bar.so
$ clang -fprofile-instr-generate -O2 -Wl,-build-id a.cpp $PWD/foo.so $PWD/bar.so -o a.exe
$ env LLVM_PROFILE_FILE="default.profraw" ./a.exe
$ llvm-profdata merge -o profdata default.profraw
$ llvm-profdata show --binary-ids default.profraw
Instrumentation level: Front-end
Total functions: 3
Maximum function count: 1
Maximum internal block count: 0
Binary IDs:
06022829f1a980398e09aa4fc4d26d78a1e9fac0
$ llvm-profdata show --binary-ids profdata
Instrumentation level: Front-end
Total functions: 3
Maximum function count: 1
Maximum internal block count: 0
Binary IDs:
06022829f1a980398e09aa4fc4d26d78a1e9fac0
$ llvm-readobj --notes bar.so
..
Build ID: 06022829f1a980398e09aa4fc4d26d78a1e9fac0
...
In this case, there are 3 raw profiles one after another in default.profraw
. Each of them has a binary id.
default.profraw
actually contains 3 binary ids for a.exe, foo.so, bar.so, verified using hexdump, butllvm-prodata show --binary-ids
is only able to show the one of them (It’s bar.so’s binary id in this case).- After merging,
profdata
only contains one binary id. Does this mean binary id is not useful anymore after merging?