[llvm] [SampleProfileMatcher] Fix backward matching of non-anchor locations (PR #190118)
Grigory Pastukhov via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 09:19:21 PDT 2026
================
@@ -234,10 +234,12 @@ SampleProfileMatcher::longestCommonSequence(const AnchorList &AnchorList1,
void SampleProfileMatcher::matchNonCallsiteLocs(
const LocToLocMap &MatchedAnchors, const AnchorMap &IRAnchors,
LocToLocMap &IRToProfileLocationMap) {
- auto InsertMatching = [&](const LineLocation &From, const LineLocation &To) {
+ auto UpdateMatching = [&](const LineLocation &From, const LineLocation &To) {
// Skip the unchanged location mapping to save memory.
if (From != To)
- IRToProfileLocationMap.insert({From, To});
+ IRToProfileLocationMap.insert_or_assign(From, To);
+ else
+ IRToProfileLocationMap.erase(From);
----------------
grigorypas wrote:
Maybe I am missing something... We start with empty map. If statement above should prevent adding pairs (or updating) when From = To. It looks like we should never have From = To in the map.
https://github.com/llvm/llvm-project/pull/190118
More information about the llvm-commits
mailing list