[llvm] [Sample Profile Loader] Fix potential invalidated reference (PR #73181)

David Li via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 21:05:45 PST 2023


david-xl wrote:

> > Previously (before md5phase2) ProfiledFunctions is a llvm::StringMap, which also have the same issue theoretically when rehashing but was not observed.
> 
> This is again the consequence of you breaking reference stability with the new container. Before your change, there is no issue with StringMap -- it guarantees reference stability and rehash does not cause the underlying StringMapEntryBase to be reallocated. The code works with the assumption of reference stability.

In all fairness, the old code was probably written without reference stability in mind -- the StringMap might be implemented without that guarantee. I think making code not depending on that behavior can be more robust and immune to breakage in the future. 

https://github.com/llvm/llvm-project/pull/73181


More information about the llvm-commits mailing list