[PATCH] D110275: [llvm-profgen] Fix a dangling vector reference in CS line number based generator

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 22 13:50:37 PDT 2021


wenlei added inline comments.


================
Comment at: llvm/tools/llvm-profgen/ProfileGenerator.cpp:228
+    SampleContext FContext(NewContext, RawContext);
+    auto Ret = ProfileMap.emplace(FContext, FunctionSamples());
     if (WasLeafInlined)
----------------
wlei wrote:
> Side note:
> 
> This might be improved in the future, if it's a new context, it will always do a twice search(find and emplace), I guess context search is heavy.
I think emplace alone is enough. The return value tells you whether the element exists, and insertion only happens when the element does not exist. Though we would need to create NewContext in Contexts first in order to combine find with emplace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110275



More information about the llvm-commits mailing list