[llvm] [CodeGen] Speed up instruction insertion with debug info (NFCI) (PR #218373)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 04:02:15 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Frank Denis (jedisct1)

<details>
<summary>Changes</summary>

Debug instructions don't have slot indexes, so no need to look them up when searching for the nearest indexed instruction.

This avoids unnecessary lookups (that would all fail) in functions with a lot of debug info.

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


1 Files Affected:

- (modified) llvm/include/llvm/CodeGen/SlotIndexes.h (+4) 


``````````diff
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index cc5143b028e88..eb9906e597f34 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -419,6 +419,8 @@ class raw_ostream;
         if (I == B)
           return getMBBStartIdx(MBB);
         --I;
+        if (I->isDebugInstr())
+          continue;
         Mi2IndexMap::const_iterator MapItr = mi2iMap.find(&*I);
         if (MapItr != mi2iMap.end())
           return MapItr->second;
@@ -436,6 +438,8 @@ class raw_ostream;
         ++I;
         if (I == E)
           return getMBBEndIdx(MBB);
+        if (I->isDebugInstr())
+          continue;
         Mi2IndexMap::const_iterator MapItr = mi2iMap.find(&*I);
         if (MapItr != mi2iMap.end())
           return MapItr->second;

``````````

</details>


https://github.com/llvm/llvm-project/pull/218373


More information about the llvm-commits mailing list