Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 16, 2025

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/MachineDebugify.cpp (+5-2)
diff --git a/llvm/lib/CodeGen/MachineDebugify.cpp b/llvm/lib/CodeGen/MachineDebugify.cpp
index bffdd51bfbca7..d0e325824c89a 100644
--- a/llvm/lib/CodeGen/MachineDebugify.cpp
+++ b/llvm/lib/CodeGen/MachineDebugify.cpp
@@ -123,10 +123,13 @@ bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
 
       // Find a suitable local variable for the DBG_VALUE.
       unsigned Line = MI.getDebugLoc().getLine();
-      if (!Line2Var.count(Line))
+      auto It = Line2Var.find(Line);
+      if (It == Line2Var.end()) {
         Line = EarliestDVI ? EarliestDVI->getDebugLoc().getLine()
                            : EarliestDVR->getDebugLoc().getLine();
-      DILocalVariable *LocalVar = Line2Var[Line];
+        It = Line2Var.try_emplace(Line).first;
+      }
+      DILocalVariable *LocalVar = It->second;
       assert(LocalVar && "No variable for current line?");
       VarSet.insert(LocalVar);
 

@kazutakahirata kazutakahirata merged commit b648576 into llvm:main Mar 16, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Debug branch March 16, 2025 18:03
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