Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

We do not modify Matchings after we call try_emplace, so we can just
std::move Matchings.

We do not modify Matchings after we call try_emplace, so we can just
std::move Matchings.
@llvmbot
Copy link
Member

llvmbot commented Feb 26, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

We do not modify Matchings after we call try_emplace, so we can just
std::move Matchings.


Full diff: https://github.com/llvm/llvm-project/pull/128933.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/MemProfiler.cpp (+2-1)
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 7d8bc3aa4c589..8149f55b46274 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -929,7 +929,8 @@ memprof::computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader,
     longestCommonSequence<LineLocation, GlobalValue::GUID>(
         ProfileAnchors, IRAnchors, std::equal_to<GlobalValue::GUID>(),
         [&](LineLocation A, LineLocation B) { Matchings.try_emplace(A, B); });
-    bool Inserted = UndriftMaps.try_emplace(CallerGUID, Matchings).second;
+    bool Inserted =
+        UndriftMaps.try_emplace(CallerGUID, std::move(Matchings)).second;
 
     // The insertion must succeed because we visit each GUID exactly once.
     assert(Inserted);

Copy link

@snehasish snehasish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kazutakahirata kazutakahirata merged commit 26ac742 into llvm:main Feb 26, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the memprof_move_matchings branch February 26, 2025 23:03
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Mar 3, 2025
We do not use Matchings after we call try_emplace, so we can just
std::move Matchings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants