[llvm] [CodeGen] Speed up instruction insertion with debug info (NFCI) (PR #218373)
Frank Denis via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 04:01:23 PDT 2026
https://github.com/jedisct1 created https://github.com/llvm/llvm-project/pull/218373
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.
>From 8417771c9055bc605eb38b0e9db1d1c678deb815 Mon Sep 17 00:00:00 2001
From: Frank Denis <github at pureftpd.org>
Date: Mon, 24 Aug 2026 12:50:43 +0200
Subject: [PATCH] [CodeGen] Speed up instruction insertion with debug info
(NFCI)
Debug instructions don't have SlotIndexes, so no need to look
them up when searching for the nearest indexed instruction.
This avoids unnecessary lookups in functions with a lot of debug
info.
---
llvm/include/llvm/CodeGen/SlotIndexes.h | 4 ++++
1 file changed, 4 insertions(+)
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;
More information about the llvm-commits
mailing list