Body samples could have count and call targets, merge them as well.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Good catch, thank you! For the test case, perhaps we can reuse the test https://github.com/llvm/llvm-project/blob/main/llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext#L6 and add some dummy call target to the inlinees. like
3: bar:10 1: 10 + 2: 10 baz:10
add test case (and minor change to use 'try_emplace' that does nothing if key presents)
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
1359–1360 | Nit: Looks like there is an existing function https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/SampleProf.cpp#L119 doing the similar thing, but I guess that requires some changes of it, I'm good for this version, note here just in case people like to refactor it in the future:) | |
llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext | ||
4 | Thanks for adding the test. |
added tests and did a small refactor.
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
1359–1360 | Thanks for the pointer. Did a little refactor in the new code path (may slightly prefer a separate refactor if the effort is larger or may affect more users) | |
llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext | ||
4 |
I see your point. The test would fail without this patch. Now with test edited this is cleaerer.
Good point. Edit this test to show profiles with the same line location are merged, and those with different line location are not. |
LGTM, thanks for the fix!
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
1359–1360 | Good idea to leverage the addSampleRecord, thanks! |
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
781 | Nit: for completeness, add the uint64_t Weight = 1 like other addXXX |
Nit: for completeness, add the uint64_t Weight = 1 like other addXXX