[llvm] [IR] Avoid redundant IRBuilder debug loc updates (PR #193018)

Clemens Wasser via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 04:36:39 PDT 2026


https://github.com/clemenswasser updated https://github.com/llvm/llvm-project/pull/193018

>From 62aa68a2744aab9fe36679dddd9cb2a19dcd9ba8 Mon Sep 17 00:00:00 2001
From: Clemens Wasser <clemens.wasser at gmail.com>
Date: Tue, 14 Apr 2026 16:54:47 +0200
Subject: [PATCH 1/2] [IR] Avoid redundant IRBuilder debug loc updates

---
 llvm/include/llvm/IR/IRBuilder.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index bdec42516b8cd..dda0ee2ac11ab 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -244,7 +244,20 @@ class IRBuilderBase {
   }
 
   /// Set location information used by debugging information.
-  void SetCurrentDebugLocation(DebugLoc L) {
+  void SetCurrentDebugLocation(const DebugLoc &L) {
+    if (StoredDL == L)
+      return;
+
+    // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
+    // to include optional introspection data for use in Debugify.
+    StoredDL = L;
+  }
+
+  /// Set location information used by debugging information.
+  void SetCurrentDebugLocation(DebugLoc &&L) {
+    if (StoredDL == L)
+      return;
+
     // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
     // to include optional introspection data for use in Debugify.
     StoredDL = std::move(L);

>From 217e1760aece5c8229537c28e0c9dee668717943 Mon Sep 17 00:00:00 2001
From: Clemens Wasser <clemens.wasser at gmail.com>
Date: Tue, 21 Apr 2026 13:36:08 +0200
Subject: [PATCH 2/2] [IR] SetCurrentDebugLocation no early exit

---
 llvm/include/llvm/IR/IRBuilder.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index dda0ee2ac11ab..6c05b3355cba6 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -245,9 +245,6 @@ class IRBuilderBase {
 
   /// Set location information used by debugging information.
   void SetCurrentDebugLocation(const DebugLoc &L) {
-    if (StoredDL == L)
-      return;
-
     // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
     // to include optional introspection data for use in Debugify.
     StoredDL = L;
@@ -255,9 +252,6 @@ class IRBuilderBase {
 
   /// Set location information used by debugging information.
   void SetCurrentDebugLocation(DebugLoc &&L) {
-    if (StoredDL == L)
-      return;
-
     // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
     // to include optional introspection data for use in Debugify.
     StoredDL = std::move(L);



More information about the llvm-commits mailing list