[PATCH] D92584: [CSSPGO][llvm-profgen] Refactor to unify hashable interface for trace sample and context-sensitive counter

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 12:22:17 PST 2020


wmi added inline comments.


================
Comment at: llvm/tools/llvm-profgen/PerfReader.h:116
+// Base class to extend for all types of perf sample
+struct PerfSample {
+  uint64_t HashCode = 0;
----------------





================
Comment at: llvm/tools/llvm-profgen/PerfReader.h:266
+// String based context id
+struct StringBasedCtxKey : public ContextKey {
+  std::string Context;
----------------
Can you use Hashable as a base class instead so you can remove the isEqual virtual function (The CRTP pattern: https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern#Static_polymorphism)? It will also simplify the interface using Hashable. 

struct StringBasedCtxKey : public Hashable<StringBasedCtxKey> {
 ...
}

And other type of Key later on:
struct ProbeBasedCtxKey : public Hashable<ProbeBasedCtxKey> {
 ...
}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92584



More information about the llvm-commits mailing list