Support of convert a regular nested profile to CS flat profile. This is useful for comparing the calling contexts in two different types of profiles.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Some linter seems legit.
llvm/lib/ProfileData/SampleProf.cpp | ||
---|---|---|
501–502 | I'm a bit confused by the name convertToCSFlatProfiles, looking at the implementation isn't this converting to nested profile? | |
553–617 | Here the caller name is convertToCSNestedProfiles, but the callee on line 552 is convertToCSFlatProfiles. | |
llvm/test/tools/llvm-profdata/cs-sample-flat-profile.test | ||
2 | Add round trip test for conversion? | |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
750–751 | Are the two flags (GenCSNestedProfile/GenCSFlatProfile and the corresponding switches) supposed to be mutually exclusive? If yes, perhaps we should make it explicit? one way to make then mutual exclusive is to use a single switch: gen-cs-nested-profile==true means nested, false means flat. Or we can have -gen-cs-profile={nest|flat}. |
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
101 | I think flat vs nest is better here (than cs vs nest). | |
382–383 | addCalledTarget does not add to NumSamples, but removeCalledTarget subtracts NumSamples. What's the reason for the inconsistency? | |
llvm/lib/ProfileData/SampleProf.cpp | ||
515 | nit: 0->ContextNone | |
527–528 | It looks like the discrepancy comes from the fact that flat profile has target counts included in total samples, but nest profile doesn't? Is this something that should be unified? I don't remember why we choose to include target counts (rather than SampleRecord::NumSamples) in total counts for flat profile. Was it intentional? |
llvm/include/llvm/ProfileData/SampleProf.h | ||
---|---|---|
101 | Sounds good. | |
382–383 | I think. It's due to the implementation of the profile generator. Callsite block samples are computed by analyzing LBR ranges, and NumSamples is updated there, while call target samples are computed based on branch samples. D122609 provides an option to make them consistent. removeCalledTarget handles both in one place. | |
llvm/lib/ProfileData/SampleProf.cpp | ||
515 | Done. | |
527–528 | The profile generator, for both flat and nest profiles, only includes callsite counts in the total count but not target counts. Ideally they would be the same. Here we are excluding target counts from callsite counts, which in turn excluded from total counts. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
831 | The boolean conversion seem to point to hasValue? I think the convention is mostly *ProfileIsCS.
| |
1026 | nit: name this convert-sample-profile-layout. otherwise having SPL_None as default can be confusing as there's no None layout. But it makes sense for conversion to be None. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
831 | I was talking about Optional<bool> ProfileIsCS. |
llvm/tools/llvm-profdata/llvm-profdata.cpp | ||
---|---|---|
831 | Oh I see. Yes, *ProfileIsCS should be used instead. Also fixed another place like this. |
I think flat vs nest is better here (than cs vs nest).