[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.
This commit is contained in:
parent
292533324c
commit
5617fb1411
|
@ -69,7 +69,7 @@ private:
|
|||
getSkipAdviceIfUnreachableCallsite(CallBase &CB);
|
||||
void print(raw_ostream &OS) const override;
|
||||
|
||||
mutable DenseMap<const Function *, FunctionPropertiesInfo> FPICache;
|
||||
mutable std::map<const Function *, FunctionPropertiesInfo> FPICache;
|
||||
|
||||
LazyCallGraph &CG;
|
||||
|
||||
|
|
|
@ -415,8 +415,8 @@ void MLInlineAdvisor::print(raw_ostream &OS) const {
|
|||
<< " EdgesOfLastSeenNodes: " << EdgesOfLastSeenNodes << "\n";
|
||||
OS << "[MLInlineAdvisor] FPI:\n";
|
||||
for (auto I : FPICache) {
|
||||
OS << I.getFirst()->getName() << ":\n";
|
||||
I.getSecond().print(OS);
|
||||
OS << I.first->getName() << ":\n";
|
||||
I.second.print(OS);
|
||||
OS << "\n";
|
||||
}
|
||||
OS << "\n";
|
||||
|
|
Loading…
Reference in New Issue