[llvm] [SampleProfileMatcher] Fix backward matching of non-anchor locations (PR #190118)
Wei Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 13:50:38 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);
----------------
apolloww wrote:
Not sure if I follow. The above only executes when `From != To`. When `From == To`, we'd need to `erase` any mapping that doesn't change location.
https://github.com/llvm/llvm-project/pull/190118
More information about the llvm-commits
mailing list