[MLGO][NFC] Use std::map instead of DenseMap to avoid use after free
authorMircea Trofin <mtrofin@google.com>
Fri, 4 Nov 2022 23:05:10 +0000 (16:05 -0700)
committerMircea Trofin <mtrofin@google.com>
Fri, 4 Nov 2022 23:07:24 +0000 (16:07 -0700)
commit5617fb1411f765667c016b5b75daa9d1110c36af
treecb195f42f718ec952d26ae913f89987bfd6843ed
parent292533324cadf0164a7e1d532508cb59775e0a72
[MLGO][NFC] Use std::map instead of DenseMap to avoid use after free

In `MLInlineAdvisor::getAdviceImpl`, we call `getCachedFPI` twice, once
for the caller, once for the callee, so the second may invalidate the
reference obtained by the first because the underlying implementation of
the cache is a `DenseMap`. `std::map` doesn't have that problem.
llvm/include/llvm/Analysis/MLInlineAdvisor.h
llvm/lib/Analysis/MLInlineAdvisor.cpp