Sample profiles are stored in a string map which is basically an unordered map. Printing out profiles by simply walking the string map doesn't enforce an order. I'm sorting the map in the decreasing order of total samples to enable a more stable dump, which is good for comparing two dumps.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/ProfileData/SampleProfReader.cpp | ||
---|---|---|
69–73 | This is duplicated of the sorting in SampleProfileWriter::writeFuncProfiles. Can we make a standalone helper in SampleProf.h to avoid duplicate? |
llvm/lib/ProfileData/SampleProfReader.cpp | ||
---|---|---|
69–73 | Good call, done. |
FYI, I ran into this commit when pulling into our downstream fork because we had some tests comparing expected profile dump output. Usually labeling a commit as "NFC" is reserved for patches that have no externally visible effect, but this changes the output of llvm-profdata show. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151234.html for recent discussion. I can certainly see this being a bit of an edge case.
(No objection to the patch itself, and we didn't see any ill effect so far, just wanted to mention this in case it was unexpectedly not-NFC, or in case anyone else runs across this commit.)
Thanks for the heads-up and sorry for the inconvenience. I agree that this patch is not a NFC.
This is duplicated of the sorting in SampleProfileWriter::writeFuncProfiles. Can we make a standalone helper in SampleProf.h to avoid duplicate?