[PATCH] D100090: [CSSPGO] Fix dangling context strings and improve profile order consistency and error handling

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 23:13:47 PDT 2021


wenlei created this revision.
wenlei added reviewers: hoy, wmi, wlei, davidxl.
Herald added subscribers: modimo, lxfind, hiraditya, eraman.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch fixed the follow issues along side with some refactoring:

1. Fix bugs where StringRef for context string out live the underlying std::string. We now keep string table in profile generator to hold std::strings. We also do the same for bracketed context strings in profile writer.
2. Make sure profile output strictly follow (total sample, name) order. Previously, there's inconsistency between ProfileMap's key and FunctionSamples's name, leading to inconsistent ordering. This is now fixed by introducing context profile canonicalization. Assertions are also added to make sure ProfileMap's key and FunctionSamples's name are always consistent.
3. Enhanced error handling for profile writing to make sure we bubble up errors properly for both llvm-profgen and llvm-profdata when string table is not populated correctly for extended binary profile.
4. Keep all internal context representation bracket free. This avoids creating new strings for context trimming, merging and preinline. getNameWithContext API is now simplied accordingly.
5. Factor out the code for context trimming and merging into SampleContextTrimmer in SampleProf.cpp. This enables llvm-profdata to use the trimmer when merging profiles. Changes in llvm-profgen will be in separate patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100090

Files:
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/ProfileData/SampleProfWriter.h
  llvm/lib/ProfileData/SampleProf.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/test/tools/llvm-profgen/recursion-compression-noprobe.test
  llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-profgen/CSPreInliner.cpp
  llvm/tools/llvm-profgen/ProfileGenerator.cpp
  llvm/tools/llvm-profgen/ProfileGenerator.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100090.336009.patch
Type: text/x-patch
Size: 28090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/9c947220/attachment-0001.bin>


More information about the llvm-commits mailing list