[llvm] [SampleProfileMatcher] Fix backward matching of non-anchor locations (PR #190118)
Grigory Pastukhov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 14:08:23 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:
I think I understand now. When From == To, you delete the old pair (From, To_old).
https://github.com/llvm/llvm-project/pull/190118
More information about the llvm-commits
mailing list