[PATCH] D56435: We can improve the performance (generally) by memo-izing the action to map a debug location to its function summary.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 13 18:20:45 PST 2019


dblaikie added inline comments.


================
Comment at: lib/Transforms/IPO/SampleProfile.cpp:728-732
+  auto it = DILocation2SampleMap.find(DIL);
+  if (it != DILocation2SampleMap.end())
+    return it->second;
+  const FunctionSamples *s = Samples->findFunctionSamples(DIL);
+  DILocation2SampleMap.try_emplace(DIL, s);
----------------
Perhaps do an unconditional try_emplace and use the bool in the returned pair to decide if the work has already been done or not? This saves two map lookups on the first lookup.

  pair<iterator, bool> p = try_emplace(DIL, nullptr);
  if (p.second)
    p.first->second = findFunctionSamples(DIL)
  return p.first->second;


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56435





More information about the llvm-commits mailing list