[PATCH] D66191: [AutoFDO] Make call targets order deterministic for sample profil

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 10:39:59 PDT 2019


wmi added a comment.

Thanks for working on it.



================
Comment at: llvm/include/llvm/ProfileData/SampleProf.h:146
 public:
-  using CallTargetMap = StringMap<uint64_t>;
+  using CallTargetMap = std::map<StringRef,uint64_t>;
 
----------------
StringMap is more effient than std::map, but I assume the call targets list won't be very long so using std::map may not be an issue for compile time. 

A problem of map is that if we want to sort CallTargetMap, I like to see the targets are sorted in count order (high to low) instead of alphabet order, so the dump will be more meaningful and we don't need sort the targets again using SortCallTargets in SampleProfile.cpp. But map cannot be internally sorted in its value_type.

How about leave CallTargetMap as a StringMap and make SortCallTargets a member function of SampleRecord and sort CallTargetMap before dumping and file writing? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66191/new/

https://reviews.llvm.org/D66191





More information about the llvm-commits mailing list