[Mlir-commits] [mlir] 62a04f9 - [IR] Deprecate Instruction::getStableDebugLoc() (#230016)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 8 01:46:11 PDT 2026


Author: Nikita Popov
Date: 2026-10-08T08:46:05Z
New Revision: 62a04f93f651a7a20d40731af539ab4fe98f06df

URL: https://github.com/llvm/llvm-project/commit/62a04f93f651a7a20d40731af539ab4fe98f06df
DIFF: https://github.com/llvm/llvm-project/commit/62a04f93f651a7a20d40731af539ab4fe98f06df.diff

LOG: [IR] Deprecate Instruction::getStableDebugLoc() (#230016)

In favor of getDebugLoc(). Since the migration from debuginfo intrinsics
to records, these are equivalent.

Added: 
    

Modified: 
    llvm/include/llvm/IR/IRBuilder.h
    llvm/include/llvm/IR/Instruction.h
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    llvm/lib/IR/BasicBlock.cpp
    llvm/lib/Transforms/IPO/ExpandVariadics.cpp
    llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
    llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
    mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    polly/lib/Analysis/ScopDetectionDiagnostic.cpp
    polly/lib/Support/ScopLocation.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 5a03972a58b4f..442cef296754a 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -207,7 +207,7 @@ class IRBuilderBase {
     BB = I->getParent();
     InsertPt = I->getIterator();
     assert(InsertPt != BB->end() && "Can't read debug loc from end()");
-    SetCurrentDebugLocation(I->getStableDebugLoc());
+    SetCurrentDebugLocation(I->getDebugLoc());
   }
 
   /// This specifies that created instructions should be inserted at the
@@ -223,7 +223,7 @@ class IRBuilderBase {
     BB = IP.getNodeParent();
     InsertPt = IP;
     if (IP != BB->end())
-      SetCurrentDebugLocation(IP->getStableDebugLoc());
+      SetCurrentDebugLocation(IP->getDebugLoc());
   }
 
   /// This specifies that created instructions should inserted at the beginning

diff  --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index 0ad9e4ff47b66..a0cc205539162 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -556,6 +556,7 @@ class Instruction : public User,
 
   /// Fetch the debug location for this node, unless this is a debug intrinsic,
   /// in which case fetch the debug location of the next non-debug node.
+  LLVM_DEPRECATED_WITH_FIXIT("Use getDebugLoc() instead", "getDebugLoc")
   LLVM_ABI const DebugLoc &getStableDebugLoc() const;
 
   /// Set or clear the nuw flag on this instruction, which must be an operator

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index e451c0c0f0f30..7fce017ca5359 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -179,7 +179,7 @@ static void restoreIPandDebugLoc(llvm::IRBuilderBase &Builder,
   // insertion function's subprogram. Prefer the block's own last instruction;
   // otherwise synthesize a location from the function's subprogram.
   if (!BB->empty())
-    Builder.SetCurrentDebugLocation(BB->back().getStableDebugLoc());
+    Builder.SetCurrentDebugLocation(BB->back().getDebugLoc());
   else if (llvm::DISubprogram *FSP =
                BB->getParent() ? BB->getParent()->getSubprogram() : nullptr) {
     unsigned Line = FSP->getScopeLine() ? FSP->getScopeLine() : FSP->getLine();

diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index d4141adf65a84..bc3a02a5d25a2 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -513,7 +513,7 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
                                        this->getNextNode());
 
   // Save DebugLoc of split point before invalidating iterator.
-  DebugLoc Loc = I->getStableDebugLoc();
+  DebugLoc Loc = I->getDebugLoc();
   if (Loc)
     Loc = Loc->getWithoutAtom();
 

diff  --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
index 483492fd0feb7..a55ba232fe175 100644
--- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
+++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp
@@ -702,7 +702,7 @@ bool ExpandVariadics::expandCall(Module &M, IRBuilder<> &Builder, CallBase *CB,
       // The va_arg lowering loads through a pointer. Set up an alloca to aim
       // that pointer at.
       Builder.SetInsertPointPastAllocas(CBF);
-      Builder.SetCurrentDebugLocation(CB->getStableDebugLoc());
+      Builder.SetCurrentDebugLocation(CB->getDebugLoc());
       Value *CallerCopy =
           Builder.CreateAlloca(UnderlyingType, nullptr, "IndirectAlloca");
 
@@ -768,7 +768,7 @@ bool ExpandVariadics::expandCall(Module &M, IRBuilder<> &Builder, CallBase *CB,
   Builder.SetInsertPointPastAllocas(CBF);
 
   // SetCurrentDebugLocation when the builder SetInsertPoint method does not
-  Builder.SetCurrentDebugLocation(CB->getStableDebugLoc());
+  Builder.SetCurrentDebugLocation(CB->getDebugLoc());
 
   // The awkward construction here is to set the alignment on the instance
   AllocaInst *Alloced = Builder.Insert(
@@ -792,7 +792,7 @@ bool ExpandVariadics::expandCall(Module &M, IRBuilder<> &Builder, CallBase *CB,
     if (!ABI->vaListPassedInSSARegister()) {
       Type *VaListTy = ABI->vaListType(Ctx);
       Builder.SetInsertPointPastAllocas(CBF);
-      Builder.SetCurrentDebugLocation(CB->getStableDebugLoc());
+      Builder.SetCurrentDebugLocation(CB->getDebugLoc());
       VaList = Builder.CreateAlloca(VaListTy, nullptr, "va_argument");
       Builder.SetInsertPoint(CB);
       Builder.CreateLifetimeStart(VaList);

diff  --git a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
index 14745dc8fcfa9..ef6d19b3413c2 100644
--- a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
+++ b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
@@ -143,7 +143,7 @@ insertLoopExpansion(Instruction *InsertBefore, Value *Len,
       InsertBefore, BBNamePrefix + "-post-expansion");
   Function *ParentFunc = PreLoopBB->getParent();
   LLVMContext &Ctx = PreLoopBB->getContext();
-  const DebugLoc &DbgLoc = InsertBefore->getStableDebugLoc();
+  const DebugLoc &DbgLoc = InsertBefore->getDebugLoc();
   IRBuilder<> PreLoopBuilder(PreLoopBB->getTerminator());
   PreLoopBuilder.SetCurrentDebugLocation(DbgLoc);
 
@@ -695,7 +695,7 @@ static void createMemMoveLoopUnknownSize(Instruction *InsertBefore,
       ConstantInt::get(ILengthType, ResidualLoopOpSize);
   ConstantInt *Zero = ConstantInt::get(ILengthType, 0);
 
-  const DebugLoc &DbgLoc = InsertBefore->getStableDebugLoc();
+  const DebugLoc &DbgLoc = InsertBefore->getDebugLoc();
   IRBuilder<> PLBuilder(InsertBefore);
   PLBuilder.SetCurrentDebugLocation(DbgLoc);
 
@@ -962,7 +962,7 @@ static void createMemMoveLoopKnownSize(Instruction *InsertBefore,
   ConstantInt *LoopBound = ConstantInt::get(ILengthType, BytesCopiedInLoop);
   ConstantInt *CILoopOpSize = ConstantInt::get(ILengthType, LoopOpSize);
 
-  const DebugLoc &DbgLoc = InsertBefore->getStableDebugLoc();
+  const DebugLoc &DbgLoc = InsertBefore->getDebugLoc();
   IRBuilder<> PLBuilder(InsertBefore);
   PLBuilder.SetCurrentDebugLocation(DbgLoc);
 
@@ -1455,7 +1455,7 @@ bool llvm::expandMemMoveAsLoop(MemMoveInst *Memmove,
   bool SrcIsVolatile = Memmove->isVolatile();
   bool DstIsVolatile = SrcIsVolatile;
   IRBuilder<> CastBuilder(Memmove);
-  CastBuilder.SetCurrentDebugLocation(Memmove->getStableDebugLoc());
+  CastBuilder.SetCurrentDebugLocation(Memmove->getDebugLoc());
 
   unsigned SrcAS = SrcAddr->getType()->getPointerAddressSpace();
   unsigned DstAS = DstAddr->getType()->getPointerAddressSpace();

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 082aada2d16c1..78776a139d717 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -8355,11 +8355,11 @@ TEST_F(OpenMPIRBuilderTest, splitBB) {
 
   Builder.SetCurrentDebugLocation(DL);
   AllocaInst *alloc = Builder.CreateAlloca(Builder.getInt32Ty());
-  EXPECT_TRUE(DL == alloc->getStableDebugLoc());
+  EXPECT_TRUE(DL == alloc->getDebugLoc());
   BasicBlock *AllocaBB = Builder.GetInsertBlock();
   splitBB(Builder, /*CreateBranch=*/true, "test");
   if (AllocaBB->getTerminator())
-    EXPECT_TRUE(DL == AllocaBB->getTerminator()->getStableDebugLoc());
+    EXPECT_TRUE(DL == AllocaBB->getTerminator()->getDebugLoc());
 }
 
 TEST_F(OpenMPIRBuilderTest, spliceBBWithEmptyBB) {

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index f9c20c7fa3457..03a95b7406893 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1999,7 +1999,7 @@ static llvm::Expected<llvm::BasicBlock *> allocatePrivateVars(
   llvm::BasicBlock *allocaBB = allocaIP.getNodeParent();
   llvm::Instruction *allocaTerminator = allocaBB->getTerminator();
   splitBB(allocaTerminator->getIterator(), true,
-          allocaTerminator->getStableDebugLoc(), "omp.region.after_alloca");
+          allocaTerminator->getDebugLoc(), "omp.region.after_alloca");
   // Update the allocaTerminator since the alloca block was split above.
   allocaTerminator = allocaBB->getTerminator();
   // The new terminator is an uncondition branch created by the splitBB above.
@@ -2014,7 +2014,7 @@ static llvm::Expected<llvm::BasicBlock *> allocatePrivateVars(
     allocatorTerminator = allocatorBB->getTerminator();
     afterAllocatorAllocations = splitBB(
         allocatorTerminator->getIterator(), true,
-        allocatorTerminator->getStableDebugLoc(), "omp.region.after_allocate");
+        allocatorTerminator->getDebugLoc(), "omp.region.after_allocate");
     allocatorTerminator = allocatorBB->getTerminator();
     assert(allocatorTerminator->getNumSuccessors() == 1 &&
            "This is an unconditional branch created by splitBB");

diff  --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
index 3daf47cae7b40..fd01b0ad16778 100644
--- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
+++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
@@ -122,7 +122,7 @@ void getDebugLocations(const BBPair &P, DebugLoc &Begin, DebugLoc &End) {
       continue;
     Todo.append(succ_begin(BB), succ_end(BB));
     for (const Instruction &Inst : *BB) {
-      DebugLoc DL = Inst.getStableDebugLoc();
+      DebugLoc DL = Inst.getDebugLoc();
       if (!DL)
         continue;
 
@@ -833,7 +833,7 @@ std::string ReportUnprofitable::getEndUserMessage() const {
 const DebugLoc &ReportUnprofitable::getDebugLoc() const {
   for (const BasicBlock *BB : R->blocks())
     for (const Instruction &Inst : *BB)
-      if (const DebugLoc &DL = Inst.getStableDebugLoc())
+      if (const DebugLoc &DL = Inst.getDebugLoc())
         return DL;
 
   return R->getEntry()->getTerminator()->getDebugLoc();

diff  --git a/polly/lib/Support/ScopLocation.cpp b/polly/lib/Support/ScopLocation.cpp
index 9f9941d57ad26..01f3d68926d88 100644
--- a/polly/lib/Support/ScopLocation.cpp
+++ b/polly/lib/Support/ScopLocation.cpp
@@ -25,7 +25,7 @@ void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
 
   for (const BasicBlock *BB : R->blocks())
     for (const Instruction &Inst : *BB) {
-      DebugLoc DL = Inst.getStableDebugLoc();
+      DebugLoc DL = Inst.getDebugLoc();
       if (!DL)
         continue;
 


        


More information about the Mlir-commits mailing list