Skip to content

[DebugInfo] Update DIBuilder insertion to take InsertPosition #126059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

hvdijk
Copy link
Contributor

@hvdijk hvdijk commented Feb 6, 2025

After #124287 updated several functions to return iterators rather than Instruction *, it was no longer straightforward to pass their result to DIBuilder. This commit updates DIBuilder methods to accept an InsertPosition instead, so that they can be called with an iterator (preferred), or with a deprecation warning an Instruction *, or a BasicBlock *. This commit also updates the existing calls to the DIBuilder methods to pass in iterators.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. debuginfo coroutines C++20 coroutines llvm:ir llvm:transforms labels Feb 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-coroutines
@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-debuginfo

Author: Harald van Dijk (hvdijk)

Changes

After #124287 updated several functions to return iterators rather than Instruction *, it was no longer straightforward to pass their result to DIBuilder. This commit updates DIBuilder methods to accept an InsertPosition instead, so that they can be called with an iterator (preferred), or with a deprecation warning an Instruction *, or a BasicBlock *. This commit also updates the existing calls to the DIBuilder methods to pass in iterators.


Patch is 35.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126059.diff

11 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+9-8)
  • (modified) llvm/include/llvm/IR/DIBuilder.h (+8-54)
  • (modified) llvm/lib/IR/DIBuilder.cpp (+28-88)
  • (modified) llvm/lib/IR/DebugInfo.cpp (+25-16)
  • (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+8-6)
  • (modified) llvm/lib/Transforms/Utils/Local.cpp (+5-17)
  • (modified) llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (+2-1)
  • (modified) llvm/unittests/IR/IRBuilderTest.cpp (+7-5)
  • (modified) llvm/unittests/Transforms/Utils/CloningTest.cpp (+3-2)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index db595796c067e98..c80bc866e31edf8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4897,7 +4897,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
                                llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                      Column, Scope,
                                                      CurInlinedAt),
-                               Builder.GetInsertBlock());
+                               Builder.GetInsertBlock()->end());
       }
     }
   }
@@ -4965,7 +4965,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5071,7 +5071,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5118,7 +5118,7 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
   DBuilder.insertLabel(L,
                        llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
                                              Scope, CurInlinedAt),
-                       Builder.GetInsertBlock());
+                       Builder.GetInsertBlock()->end());
 }
 
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
@@ -5196,9 +5196,10 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
                                   LexicalBlockStack.back(), CurInlinedAt);
   auto *Expr = DBuilder.createExpression(addr);
   if (InsertPoint)
-    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);
+    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint->getIterator());
   else
-    DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock());
+    DBuilder.insertDeclare(Storage, D, Expr, DL,
+                           Builder.GetInsertBlock()->end());
 }
 
 llvm::DILocalVariable *
@@ -5381,7 +5382,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
   DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
                          llvm::DILocation::get(CGM.getLLVMContext(), line,
                                                column, scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 }
 
 llvm::DIDerivedType *
@@ -5861,7 +5862,7 @@ void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
 
   if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
     DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL,
-                                     &**InsertPoint);
+                                     *InsertPoint);
   }
 }
 
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 6c479415b9ed274..71455a9337b1fa9 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -92,33 +92,15 @@ namespace llvm {
     /// Create an \a temporary node and track it in \a UnresolvedNodes.
     void trackIfUnresolved(MDNode *N);
 
-    /// Internal helper for insertDeclare.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertBB, Instruction *InsertBefore);
-
-    /// Internal helper for insertLabel.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertBB, Instruction *InsertBefore);
-
     /// Internal helper. Track metadata if untracked and insert \p DVR.
-    void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
-                                 Instruction *InsertBefore,
-                                 bool InsertAtHead = false);
+    void insertDbgVariableRecord(DbgVariableRecord *DVR,
+                                 InsertPosition InsertPt);
 
     /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
     Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
                                     DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore);
-
-    /// Internal helper for insertDbgValueIntrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertBB,
-                                       Instruction *InsertBefore);
+                                    InsertPosition InsertPt);
 
   public:
     /// Construct a builder for a module.
@@ -959,16 +941,6 @@ namespace llvm {
                                                 StringRef Name = "",
                                                 DINodeArray Elements = nullptr);
 
-    /// Insert a new llvm.dbg.declare intrinsic call.
-    /// \param Storage     llvm::Value of the variable
-    /// \param VarInfo     Variable's debug info descriptor.
-    /// \param Expr        A complex location expression.
-    /// \param DL          Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertAtEnd);
-
     /// Insert a new llvm.dbg.assign intrinsic call.
     /// \param LinkedInstr   Instruction with a DIAssignID to link with the new
     ///                      intrinsic. The intrinsic will be inserted after
@@ -993,46 +965,28 @@ namespace llvm {
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
                              DIExpression *Expr, const DILocation *DL,
-                             Instruction *InsertBefore);
+                             InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.label intrinsic call.
     /// \param LabelInfo    Label's debug info descriptor.
     /// \param DL           Debug info location.
     /// \param InsertBefore Location for the new intrinsic.
     DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           Instruction *InsertBefore);
-
-    /// Insert a new llvm.dbg.label intrinsic call.
-    /// \param LabelInfo    Label's debug info descriptor.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertAtEnd);
-
-    /// Insert a new llvm.dbg.value intrinsic call.
-    /// \param Val          llvm::Value of the variable
-    /// \param VarInfo      Variable's debug info descriptor.
-    /// \param Expr         A complex location expression.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertAtEnd);
+                           InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.value intrinsic call.
     /// \param Val          llvm::Value of the variable
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
                                        DILocalVariable *VarInfo,
                                        DIExpression *Expr, const DILocation *DL,
-                                       Instruction *InsertBefore);
+                                       InsertPosition InsertPt);
 
     /// Replace the vtable holder in the given type.
     ///
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 8f9462ab46d8852..0ccf43a29ca01d6 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -959,22 +959,6 @@ DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
                                      File, Line, Col);
 }
 
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    Instruction *InsertBefore) {
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertBefore->getParent(),
-                       InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertAtEnd) {
-  // If this block already has a terminator then insert this intrinsic before
-  // the terminator. Otherwise, put it at the end of the block.
-  Instruction *InsertBefore = InsertAtEnd->getTerminator();
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertAtEnd, InsertBefore);
-}
-
 DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
                                       DILocalVariable *SrcVar,
                                       DIExpression *ValExpr, Value *Addr,
@@ -987,11 +971,10 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR = DbgVariableRecord::createDVRAssign(
         Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL);
-    BasicBlock *InsertBB = LinkedInstr->getParent();
     // Insert after LinkedInstr.
     BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator());
-    Instruction *InsertBefore = NextIt == InsertBB->end() ? nullptr : &*NextIt;
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore, true);
+    NextIt.setHeadBit(true);
+    insertDbgVariableRecord(DVR, NextIt);
     return DVR;
   }
 
@@ -1017,47 +1000,11 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   return DVI;
 }
 
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  Instruction *InsertBefore) {
-  return insertLabel(LabelInfo, DL,
-                     InsertBefore ? InsertBefore->getParent() : nullptr,
-                     InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertAtEnd) {
-  return insertLabel(LabelInfo, DL, InsertAtEnd, nullptr);
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              Instruction *InsertBefore) {
-  DbgInstPtr DVI = insertDbgValueIntrinsic(
-      V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
-      InsertBefore);
-  if (auto *Inst = dyn_cast<Instruction *>(DVI))
-    cast<CallInst>(Inst)->setTailCall();
-  return DVI;
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              BasicBlock *InsertAtEnd) {
-  return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
-}
-
 /// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
 /// This abstracts over the various ways to specify an insert position.
 static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
-                          BasicBlock *InsertBB, Instruction *InsertBefore) {
-  if (InsertBefore)
-    Builder.SetInsertPoint(InsertBefore);
-  else if (InsertBB)
-    Builder.SetInsertPoint(InsertBB);
+                          InsertPosition InsertPt) {
+  Builder.SetInsertPoint(InsertPt.getBasicBlock(), InsertPt);
   Builder.SetCurrentDebugLocation(DL);
 }
 
@@ -1070,26 +1017,28 @@ static Function *getDeclareIntrin(Module &M) {
   return Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare);
 }
 
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
-    llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
-    const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
+DbgInstPtr DIBuilder::insertDbgValueIntrinsic(llvm::Value *Val,
+                                              DILocalVariable *VarInfo,
+                                              DIExpression *Expr,
+                                              const DILocation *DL,
+                                              InsertPosition InsertPt) {
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDbgVariableRecord(Val, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
   if (!ValueFn)
     ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value);
-  return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
-                            InsertBefore);
+  auto *DVI = insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertPt);
+  cast<CallInst>(DVI)->setTailCall();
+  return DVI;
 }
 
 DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore) {
+                                    InsertPosition InsertPt) {
   assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1099,7 +1048,7 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
@@ -1113,35 +1062,27 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(DeclareFn, Args);
 }
 
 void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR,
-                                        BasicBlock *InsertBB,
-                                        Instruction *InsertBefore,
-                                        bool InsertAtHead) {
-  assert(InsertBefore || InsertBB);
+                                        InsertPosition InsertPt) {
+  assert(InsertPt.isValid());
   trackIfUnresolved(DVR->getVariable());
   trackIfUnresolved(DVR->getExpression());
   if (DVR->isDbgAssign())
     trackIfUnresolved(DVR->getAddressExpression());
 
-  BasicBlock::iterator InsertPt;
-  if (InsertBB && InsertBefore)
-    InsertPt = InsertBefore->getIterator();
-  else if (InsertBB)
-    InsertPt = InsertBB->end();
-  InsertPt.setHeadBit(InsertAtHead);
-  InsertBB->insertDbgRecordBefore(DVR, InsertPt);
+  auto *BB = InsertPt.getBasicBlock();
+  BB->insertDbgRecordBefore(DVR, InsertPt);
 }
 
 Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                                            Value *V, DILocalVariable *VarInfo,
                                            DIExpression *Expr,
                                            const DILocation *DL,
-                                           BasicBlock *InsertBB,
-                                           Instruction *InsertBefore) {
+                                           InsertPosition InsertPt) {
   assert(IntrinsicFn && "must pass a non-null intrinsic function");
   assert(V && "must pass a value to a dbg intrinsic");
   assert(VarInfo &&
@@ -1158,13 +1099,12 @@ Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(IntrinsicFn, Args);
 }
 
 DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertBB,
-                                  Instruction *InsertBefore) {
+                                  InsertPosition InsertPt) {
   assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1174,10 +1114,10 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   trackIfUnresolved(LabelInfo);
   if (M.IsNewDbgInfoFormat) {
     DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL);
-    if (InsertBB && InsertBefore)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBefore->getIterator());
-    else if (InsertBB)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBB->end());
+    if (InsertPt.isValid()) {
+      auto *BB = InsertPt.getBasicBlock();
+      BB->insertDbgRecordBefore(DLR, InsertPt);
+    }
     return DLR;
   }
 
@@ -1187,7 +1127,7 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(LabelFn, Args);
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea6..5b825d6df5e08e1 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1686,7 +1686,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
       unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
-      unwrap<Instruction>(Instr));
+      Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator())
+            : nullptr);
   // This assert will fail if the module is in the old debug info format.
   // This function should only be called if the module is in the new
   // debug info format.
@@ -1702,7 +1703,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
     LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
-      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
+      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
+      Block ? InsertPositi...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-llvm-ir

Author: Harald van Dijk (hvdijk)

Changes

After #124287 updated several functions to return iterators rather than Instruction *, it was no longer straightforward to pass their result to DIBuilder. This commit updates DIBuilder methods to accept an InsertPosition instead, so that they can be called with an iterator (preferred), or with a deprecation warning an Instruction *, or a BasicBlock *. This commit also updates the existing calls to the DIBuilder methods to pass in iterators.


Patch is 35.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126059.diff

11 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+9-8)
  • (modified) llvm/include/llvm/IR/DIBuilder.h (+8-54)
  • (modified) llvm/lib/IR/DIBuilder.cpp (+28-88)
  • (modified) llvm/lib/IR/DebugInfo.cpp (+25-16)
  • (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+8-6)
  • (modified) llvm/lib/Transforms/Utils/Local.cpp (+5-17)
  • (modified) llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (+2-1)
  • (modified) llvm/unittests/IR/IRBuilderTest.cpp (+7-5)
  • (modified) llvm/unittests/Transforms/Utils/CloningTest.cpp (+3-2)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index db595796c067e98..c80bc866e31edf8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4897,7 +4897,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
                                llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                      Column, Scope,
                                                      CurInlinedAt),
-                               Builder.GetInsertBlock());
+                               Builder.GetInsertBlock()->end());
       }
     }
   }
@@ -4965,7 +4965,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5071,7 +5071,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5118,7 +5118,7 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
   DBuilder.insertLabel(L,
                        llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
                                              Scope, CurInlinedAt),
-                       Builder.GetInsertBlock());
+                       Builder.GetInsertBlock()->end());
 }
 
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
@@ -5196,9 +5196,10 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
                                   LexicalBlockStack.back(), CurInlinedAt);
   auto *Expr = DBuilder.createExpression(addr);
   if (InsertPoint)
-    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);
+    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint->getIterator());
   else
-    DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock());
+    DBuilder.insertDeclare(Storage, D, Expr, DL,
+                           Builder.GetInsertBlock()->end());
 }
 
 llvm::DILocalVariable *
@@ -5381,7 +5382,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
   DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
                          llvm::DILocation::get(CGM.getLLVMContext(), line,
                                                column, scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 }
 
 llvm::DIDerivedType *
@@ -5861,7 +5862,7 @@ void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
 
   if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
     DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL,
-                                     &**InsertPoint);
+                                     *InsertPoint);
   }
 }
 
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 6c479415b9ed274..71455a9337b1fa9 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -92,33 +92,15 @@ namespace llvm {
     /// Create an \a temporary node and track it in \a UnresolvedNodes.
     void trackIfUnresolved(MDNode *N);
 
-    /// Internal helper for insertDeclare.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertBB, Instruction *InsertBefore);
-
-    /// Internal helper for insertLabel.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertBB, Instruction *InsertBefore);
-
     /// Internal helper. Track metadata if untracked and insert \p DVR.
-    void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
-                                 Instruction *InsertBefore,
-                                 bool InsertAtHead = false);
+    void insertDbgVariableRecord(DbgVariableRecord *DVR,
+                                 InsertPosition InsertPt);
 
     /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
     Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
                                     DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore);
-
-    /// Internal helper for insertDbgValueIntrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertBB,
-                                       Instruction *InsertBefore);
+                                    InsertPosition InsertPt);
 
   public:
     /// Construct a builder for a module.
@@ -959,16 +941,6 @@ namespace llvm {
                                                 StringRef Name = "",
                                                 DINodeArray Elements = nullptr);
 
-    /// Insert a new llvm.dbg.declare intrinsic call.
-    /// \param Storage     llvm::Value of the variable
-    /// \param VarInfo     Variable's debug info descriptor.
-    /// \param Expr        A complex location expression.
-    /// \param DL          Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertAtEnd);
-
     /// Insert a new llvm.dbg.assign intrinsic call.
     /// \param LinkedInstr   Instruction with a DIAssignID to link with the new
     ///                      intrinsic. The intrinsic will be inserted after
@@ -993,46 +965,28 @@ namespace llvm {
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
                              DIExpression *Expr, const DILocation *DL,
-                             Instruction *InsertBefore);
+                             InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.label intrinsic call.
     /// \param LabelInfo    Label's debug info descriptor.
     /// \param DL           Debug info location.
     /// \param InsertBefore Location for the new intrinsic.
     DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           Instruction *InsertBefore);
-
-    /// Insert a new llvm.dbg.label intrinsic call.
-    /// \param LabelInfo    Label's debug info descriptor.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertAtEnd);
-
-    /// Insert a new llvm.dbg.value intrinsic call.
-    /// \param Val          llvm::Value of the variable
-    /// \param VarInfo      Variable's debug info descriptor.
-    /// \param Expr         A complex location expression.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertAtEnd);
+                           InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.value intrinsic call.
     /// \param Val          llvm::Value of the variable
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
                                        DILocalVariable *VarInfo,
                                        DIExpression *Expr, const DILocation *DL,
-                                       Instruction *InsertBefore);
+                                       InsertPosition InsertPt);
 
     /// Replace the vtable holder in the given type.
     ///
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 8f9462ab46d8852..0ccf43a29ca01d6 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -959,22 +959,6 @@ DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
                                      File, Line, Col);
 }
 
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    Instruction *InsertBefore) {
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertBefore->getParent(),
-                       InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertAtEnd) {
-  // If this block already has a terminator then insert this intrinsic before
-  // the terminator. Otherwise, put it at the end of the block.
-  Instruction *InsertBefore = InsertAtEnd->getTerminator();
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertAtEnd, InsertBefore);
-}
-
 DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
                                       DILocalVariable *SrcVar,
                                       DIExpression *ValExpr, Value *Addr,
@@ -987,11 +971,10 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR = DbgVariableRecord::createDVRAssign(
         Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL);
-    BasicBlock *InsertBB = LinkedInstr->getParent();
     // Insert after LinkedInstr.
     BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator());
-    Instruction *InsertBefore = NextIt == InsertBB->end() ? nullptr : &*NextIt;
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore, true);
+    NextIt.setHeadBit(true);
+    insertDbgVariableRecord(DVR, NextIt);
     return DVR;
   }
 
@@ -1017,47 +1000,11 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   return DVI;
 }
 
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  Instruction *InsertBefore) {
-  return insertLabel(LabelInfo, DL,
-                     InsertBefore ? InsertBefore->getParent() : nullptr,
-                     InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertAtEnd) {
-  return insertLabel(LabelInfo, DL, InsertAtEnd, nullptr);
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              Instruction *InsertBefore) {
-  DbgInstPtr DVI = insertDbgValueIntrinsic(
-      V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
-      InsertBefore);
-  if (auto *Inst = dyn_cast<Instruction *>(DVI))
-    cast<CallInst>(Inst)->setTailCall();
-  return DVI;
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              BasicBlock *InsertAtEnd) {
-  return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
-}
-
 /// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
 /// This abstracts over the various ways to specify an insert position.
 static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
-                          BasicBlock *InsertBB, Instruction *InsertBefore) {
-  if (InsertBefore)
-    Builder.SetInsertPoint(InsertBefore);
-  else if (InsertBB)
-    Builder.SetInsertPoint(InsertBB);
+                          InsertPosition InsertPt) {
+  Builder.SetInsertPoint(InsertPt.getBasicBlock(), InsertPt);
   Builder.SetCurrentDebugLocation(DL);
 }
 
@@ -1070,26 +1017,28 @@ static Function *getDeclareIntrin(Module &M) {
   return Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare);
 }
 
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
-    llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
-    const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
+DbgInstPtr DIBuilder::insertDbgValueIntrinsic(llvm::Value *Val,
+                                              DILocalVariable *VarInfo,
+                                              DIExpression *Expr,
+                                              const DILocation *DL,
+                                              InsertPosition InsertPt) {
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDbgVariableRecord(Val, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
   if (!ValueFn)
     ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value);
-  return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
-                            InsertBefore);
+  auto *DVI = insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertPt);
+  cast<CallInst>(DVI)->setTailCall();
+  return DVI;
 }
 
 DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore) {
+                                    InsertPosition InsertPt) {
   assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1099,7 +1048,7 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
@@ -1113,35 +1062,27 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(DeclareFn, Args);
 }
 
 void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR,
-                                        BasicBlock *InsertBB,
-                                        Instruction *InsertBefore,
-                                        bool InsertAtHead) {
-  assert(InsertBefore || InsertBB);
+                                        InsertPosition InsertPt) {
+  assert(InsertPt.isValid());
   trackIfUnresolved(DVR->getVariable());
   trackIfUnresolved(DVR->getExpression());
   if (DVR->isDbgAssign())
     trackIfUnresolved(DVR->getAddressExpression());
 
-  BasicBlock::iterator InsertPt;
-  if (InsertBB && InsertBefore)
-    InsertPt = InsertBefore->getIterator();
-  else if (InsertBB)
-    InsertPt = InsertBB->end();
-  InsertPt.setHeadBit(InsertAtHead);
-  InsertBB->insertDbgRecordBefore(DVR, InsertPt);
+  auto *BB = InsertPt.getBasicBlock();
+  BB->insertDbgRecordBefore(DVR, InsertPt);
 }
 
 Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                                            Value *V, DILocalVariable *VarInfo,
                                            DIExpression *Expr,
                                            const DILocation *DL,
-                                           BasicBlock *InsertBB,
-                                           Instruction *InsertBefore) {
+                                           InsertPosition InsertPt) {
   assert(IntrinsicFn && "must pass a non-null intrinsic function");
   assert(V && "must pass a value to a dbg intrinsic");
   assert(VarInfo &&
@@ -1158,13 +1099,12 @@ Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(IntrinsicFn, Args);
 }
 
 DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertBB,
-                                  Instruction *InsertBefore) {
+                                  InsertPosition InsertPt) {
   assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1174,10 +1114,10 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   trackIfUnresolved(LabelInfo);
   if (M.IsNewDbgInfoFormat) {
     DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL);
-    if (InsertBB && InsertBefore)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBefore->getIterator());
-    else if (InsertBB)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBB->end());
+    if (InsertPt.isValid()) {
+      auto *BB = InsertPt.getBasicBlock();
+      BB->insertDbgRecordBefore(DLR, InsertPt);
+    }
     return DLR;
   }
 
@@ -1187,7 +1127,7 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(LabelFn, Args);
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea6..5b825d6df5e08e1 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1686,7 +1686,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
       unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
-      unwrap<Instruction>(Instr));
+      Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator())
+            : nullptr);
   // This assert will fail if the module is in the old debug info format.
   // This function should only be called if the module is in the new
   // debug info format.
@@ -1702,7 +1703,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
     LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
-      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
+      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
+      Block ? InsertPositi...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-clang-codegen

Author: Harald van Dijk (hvdijk)

Changes

After #124287 updated several functions to return iterators rather than Instruction *, it was no longer straightforward to pass their result to DIBuilder. This commit updates DIBuilder methods to accept an InsertPosition instead, so that they can be called with an iterator (preferred), or with a deprecation warning an Instruction *, or a BasicBlock *. This commit also updates the existing calls to the DIBuilder methods to pass in iterators.


Patch is 35.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126059.diff

11 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+9-8)
  • (modified) llvm/include/llvm/IR/DIBuilder.h (+8-54)
  • (modified) llvm/lib/IR/DIBuilder.cpp (+28-88)
  • (modified) llvm/lib/IR/DebugInfo.cpp (+25-16)
  • (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+8-6)
  • (modified) llvm/lib/Transforms/Utils/Local.cpp (+5-17)
  • (modified) llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (+2-1)
  • (modified) llvm/unittests/IR/IRBuilderTest.cpp (+7-5)
  • (modified) llvm/unittests/Transforms/Utils/CloningTest.cpp (+3-2)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index db595796c067e98..c80bc866e31edf8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4897,7 +4897,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
                                llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                      Column, Scope,
                                                      CurInlinedAt),
-                               Builder.GetInsertBlock());
+                               Builder.GetInsertBlock()->end());
       }
     }
   }
@@ -4965,7 +4965,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5071,7 +5071,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
   DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
                          llvm::DILocation::get(CGM.getLLVMContext(), Line,
                                                Column, Scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 
   return D;
 }
@@ -5118,7 +5118,7 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
   DBuilder.insertLabel(L,
                        llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
                                              Scope, CurInlinedAt),
-                       Builder.GetInsertBlock());
+                       Builder.GetInsertBlock()->end());
 }
 
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
@@ -5196,9 +5196,10 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
                                   LexicalBlockStack.back(), CurInlinedAt);
   auto *Expr = DBuilder.createExpression(addr);
   if (InsertPoint)
-    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);
+    DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint->getIterator());
   else
-    DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock());
+    DBuilder.insertDeclare(Storage, D, Expr, DL,
+                           Builder.GetInsertBlock()->end());
 }
 
 llvm::DILocalVariable *
@@ -5381,7 +5382,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
   DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
                          llvm::DILocation::get(CGM.getLLVMContext(), line,
                                                column, scope, CurInlinedAt),
-                         Builder.GetInsertBlock());
+                         Builder.GetInsertBlock()->end());
 }
 
 llvm::DIDerivedType *
@@ -5861,7 +5862,7 @@ void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
 
   if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
     DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL,
-                                     &**InsertPoint);
+                                     *InsertPoint);
   }
 }
 
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 6c479415b9ed274..71455a9337b1fa9 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -92,33 +92,15 @@ namespace llvm {
     /// Create an \a temporary node and track it in \a UnresolvedNodes.
     void trackIfUnresolved(MDNode *N);
 
-    /// Internal helper for insertDeclare.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertBB, Instruction *InsertBefore);
-
-    /// Internal helper for insertLabel.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertBB, Instruction *InsertBefore);
-
     /// Internal helper. Track metadata if untracked and insert \p DVR.
-    void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
-                                 Instruction *InsertBefore,
-                                 bool InsertAtHead = false);
+    void insertDbgVariableRecord(DbgVariableRecord *DVR,
+                                 InsertPosition InsertPt);
 
     /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
     Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
                                     DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore);
-
-    /// Internal helper for insertDbgValueIntrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertBB,
-                                       Instruction *InsertBefore);
+                                    InsertPosition InsertPt);
 
   public:
     /// Construct a builder for a module.
@@ -959,16 +941,6 @@ namespace llvm {
                                                 StringRef Name = "",
                                                 DINodeArray Elements = nullptr);
 
-    /// Insert a new llvm.dbg.declare intrinsic call.
-    /// \param Storage     llvm::Value of the variable
-    /// \param VarInfo     Variable's debug info descriptor.
-    /// \param Expr        A complex location expression.
-    /// \param DL          Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
-                             DIExpression *Expr, const DILocation *DL,
-                             BasicBlock *InsertAtEnd);
-
     /// Insert a new llvm.dbg.assign intrinsic call.
     /// \param LinkedInstr   Instruction with a DIAssignID to link with the new
     ///                      intrinsic. The intrinsic will be inserted after
@@ -993,46 +965,28 @@ namespace llvm {
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
                              DIExpression *Expr, const DILocation *DL,
-                             Instruction *InsertBefore);
+                             InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.label intrinsic call.
     /// \param LabelInfo    Label's debug info descriptor.
     /// \param DL           Debug info location.
     /// \param InsertBefore Location for the new intrinsic.
     DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           Instruction *InsertBefore);
-
-    /// Insert a new llvm.dbg.label intrinsic call.
-    /// \param LabelInfo    Label's debug info descriptor.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                           BasicBlock *InsertAtEnd);
-
-    /// Insert a new llvm.dbg.value intrinsic call.
-    /// \param Val          llvm::Value of the variable
-    /// \param VarInfo      Variable's debug info descriptor.
-    /// \param Expr         A complex location expression.
-    /// \param DL           Debug info location.
-    /// \param InsertAtEnd Location for the new intrinsic.
-    DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
-                                       DILocalVariable *VarInfo,
-                                       DIExpression *Expr, const DILocation *DL,
-                                       BasicBlock *InsertAtEnd);
+                           InsertPosition InsertPt);
 
     /// Insert a new llvm.dbg.value intrinsic call.
     /// \param Val          llvm::Value of the variable
     /// \param VarInfo      Variable's debug info descriptor.
     /// \param Expr         A complex location expression.
     /// \param DL           Debug info location.
-    /// \param InsertBefore Location for the new intrinsic.
+    /// \param InsertPt     Location for the new intrinsic.
     DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
                                        DILocalVariable *VarInfo,
                                        DIExpression *Expr, const DILocation *DL,
-                                       Instruction *InsertBefore);
+                                       InsertPosition InsertPt);
 
     /// Replace the vtable holder in the given type.
     ///
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 8f9462ab46d8852..0ccf43a29ca01d6 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -959,22 +959,6 @@ DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
                                      File, Line, Col);
 }
 
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    Instruction *InsertBefore) {
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertBefore->getParent(),
-                       InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
-                                    DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertAtEnd) {
-  // If this block already has a terminator then insert this intrinsic before
-  // the terminator. Otherwise, put it at the end of the block.
-  Instruction *InsertBefore = InsertAtEnd->getTerminator();
-  return insertDeclare(Storage, VarInfo, Expr, DL, InsertAtEnd, InsertBefore);
-}
-
 DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
                                       DILocalVariable *SrcVar,
                                       DIExpression *ValExpr, Value *Addr,
@@ -987,11 +971,10 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR = DbgVariableRecord::createDVRAssign(
         Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL);
-    BasicBlock *InsertBB = LinkedInstr->getParent();
     // Insert after LinkedInstr.
     BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator());
-    Instruction *InsertBefore = NextIt == InsertBB->end() ? nullptr : &*NextIt;
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore, true);
+    NextIt.setHeadBit(true);
+    insertDbgVariableRecord(DVR, NextIt);
     return DVR;
   }
 
@@ -1017,47 +1000,11 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
   return DVI;
 }
 
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  Instruction *InsertBefore) {
-  return insertLabel(LabelInfo, DL,
-                     InsertBefore ? InsertBefore->getParent() : nullptr,
-                     InsertBefore);
-}
-
-DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertAtEnd) {
-  return insertLabel(LabelInfo, DL, InsertAtEnd, nullptr);
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              Instruction *InsertBefore) {
-  DbgInstPtr DVI = insertDbgValueIntrinsic(
-      V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
-      InsertBefore);
-  if (auto *Inst = dyn_cast<Instruction *>(DVI))
-    cast<CallInst>(Inst)->setTailCall();
-  return DVI;
-}
-
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
-                                              DILocalVariable *VarInfo,
-                                              DIExpression *Expr,
-                                              const DILocation *DL,
-                                              BasicBlock *InsertAtEnd) {
-  return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
-}
-
 /// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
 /// This abstracts over the various ways to specify an insert position.
 static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
-                          BasicBlock *InsertBB, Instruction *InsertBefore) {
-  if (InsertBefore)
-    Builder.SetInsertPoint(InsertBefore);
-  else if (InsertBB)
-    Builder.SetInsertPoint(InsertBB);
+                          InsertPosition InsertPt) {
+  Builder.SetInsertPoint(InsertPt.getBasicBlock(), InsertPt);
   Builder.SetCurrentDebugLocation(DL);
 }
 
@@ -1070,26 +1017,28 @@ static Function *getDeclareIntrin(Module &M) {
   return Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare);
 }
 
-DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
-    llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
-    const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
+DbgInstPtr DIBuilder::insertDbgValueIntrinsic(llvm::Value *Val,
+                                              DILocalVariable *VarInfo,
+                                              DIExpression *Expr,
+                                              const DILocation *DL,
+                                              InsertPosition InsertPt) {
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDbgVariableRecord(Val, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
   if (!ValueFn)
     ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value);
-  return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
-                            InsertBefore);
+  auto *DVI = insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertPt);
+  cast<CallInst>(DVI)->setTailCall();
+  return DVI;
 }
 
 DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                                     DIExpression *Expr, const DILocation *DL,
-                                    BasicBlock *InsertBB,
-                                    Instruction *InsertBefore) {
+                                    InsertPosition InsertPt) {
   assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1099,7 +1048,7 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
   if (M.IsNewDbgInfoFormat) {
     DbgVariableRecord *DVR =
         DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL);
-    insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
+    insertDbgVariableRecord(DVR, InsertPt);
     return DVR;
   }
 
@@ -1113,35 +1062,27 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(DeclareFn, Args);
 }
 
 void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR,
-                                        BasicBlock *InsertBB,
-                                        Instruction *InsertBefore,
-                                        bool InsertAtHead) {
-  assert(InsertBefore || InsertBB);
+                                        InsertPosition InsertPt) {
+  assert(InsertPt.isValid());
   trackIfUnresolved(DVR->getVariable());
   trackIfUnresolved(DVR->getExpression());
   if (DVR->isDbgAssign())
     trackIfUnresolved(DVR->getAddressExpression());
 
-  BasicBlock::iterator InsertPt;
-  if (InsertBB && InsertBefore)
-    InsertPt = InsertBefore->getIterator();
-  else if (InsertBB)
-    InsertPt = InsertBB->end();
-  InsertPt.setHeadBit(InsertAtHead);
-  InsertBB->insertDbgRecordBefore(DVR, InsertPt);
+  auto *BB = InsertPt.getBasicBlock();
+  BB->insertDbgRecordBefore(DVR, InsertPt);
 }
 
 Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                                            Value *V, DILocalVariable *VarInfo,
                                            DIExpression *Expr,
                                            const DILocation *DL,
-                                           BasicBlock *InsertBB,
-                                           Instruction *InsertBefore) {
+                                           InsertPosition InsertPt) {
   assert(IntrinsicFn && "must pass a non-null intrinsic function");
   assert(V && "must pass a value to a dbg intrinsic");
   assert(VarInfo &&
@@ -1158,13 +1099,12 @@ Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
                    MetadataAsValue::get(VMContext, Expr)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(IntrinsicFn, Args);
 }
 
 DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
-                                  BasicBlock *InsertBB,
-                                  Instruction *InsertBefore) {
+                                  InsertPosition InsertPt) {
   assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
   assert(DL && "Expected debug loc");
   assert(DL->getScope()->getSubprogram() ==
@@ -1174,10 +1114,10 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   trackIfUnresolved(LabelInfo);
   if (M.IsNewDbgInfoFormat) {
     DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL);
-    if (InsertBB && InsertBefore)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBefore->getIterator());
-    else if (InsertBB)
-      InsertBB->insertDbgRecordBefore(DLR, InsertBB->end());
+    if (InsertPt.isValid()) {
+      auto *BB = InsertPt.getBasicBlock();
+      BB->insertDbgRecordBefore(DLR, InsertPt);
+    }
     return DLR;
   }
 
@@ -1187,7 +1127,7 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
   Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
 
   IRBuilder<> B(DL->getContext());
-  initIRBuilder(B, DL, InsertBB, InsertBefore);
+  initIRBuilder(B, DL, InsertPt);
   return B.CreateCall(LabelFn, Args);
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea6..5b825d6df5e08e1 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1686,7 +1686,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
       unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
-      unwrap<Instruction>(Instr));
+      Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator())
+            : nullptr);
   // This assert will fail if the module is in the old debug info format.
   // This function should only be called if the module is in the new
   // debug info format.
@@ -1702,7 +1703,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
     LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
   DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
       unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
-      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
+      unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
+      Block ? InsertPositi...
[truncated]

@hvdijk hvdijk requested review from jmorse and SLTozer February 6, 2025 12:59
Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for putting this all together, one nit inline,

Is this intended to be cherry-picked into the release branch or not? Seeing how the original motivation was to ease downstream compatibilities, I'd assumed there'd be the need for something to be cherry-picked, and this might be too invasive at this stage to be moved across. I don't have a full understanding of the use case though.

@OCHyams I believe you did the C API changes, are there any additional concerns in this area?

@hvdijk
Copy link
Contributor Author

hvdijk commented Feb 7, 2025

Is this intended to be cherry-picked into the release branch or not?

Yes, I was hoping that we were still early enough to be able to cherry-pick it without issues, especially as the aim is to restore a certain level of compatibility with previous LLVM releases. If that is not the case though, then at least it will be helpful to know that only LLVM 20 will require workarounds.

After llvm#124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
@hvdijk hvdijk force-pushed the dibuilder-insertposition branch from a815481 to 6929e0a Compare February 7, 2025 17:39
Copy link
Contributor

@OCHyams OCHyams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OCHyams I believe you did the C API changes, are there any additional concerns in this area?

SGTM, just one inline question

Comment on lines +1689 to +1690
Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator())
: nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this trip an assertion in the nullptr InsertPosition case (assert(InsertPt.isValid()); in insertDbgVariableRecord called by insertDeclare). Or am I reading this wrong? (Same question applies to the other calls below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Previously, a call with !Instr would result in a call to insertDeclare(..., /*InsertBefore=*/nullptr) which results in insertDeclare(..., /*InsertBB=*/nullptr->getParent(), /*InsertBefore=*/nullptr), so it would (on typical systems) result in a crash already.

At the same time, previously, insertLabel(..., /*InsertBefore=*/nullptr) would result in insertLabel(..., /*InsertBB=*/nullptr, /*InsertBefore=*/nullptr) which specifically does not insert anything.

And insertDbgValueIntrinsic(..., /*InsertBefore=*/nullptr) is special-cased to call insertDbgValueIntrinsic(..., /*InsertBB=*/nullptr, /*InsertBefore=*/nullptr) the same way, but the latter calls insertDbgVariableRecord unconditionally and hits the existing assert(InsertBefore || InsertBB); assert.

This is a messy situation and in this PR I tried to just keep that exactly the same. What previously worked should still work. What previously didn't work should still not work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for unpicking that.

This is a messy situation and in this PR I tried to just keep that exactly the same. What previously worked should still work. What previously didn't work should still not work.

SGTM. I feel as though these functions should probably have asserts in them saying as such but that could reasonably be argued to be out of scope of the patch.

Patch LGTM to me too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think for consistency, it would be nice to update these functions so that they all treat nullptr consistently, as a request to create whatever the function says to create but not insert it anywhere. When I have some extra time I'll see if that's easy to do.

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too; thanks for running with this!

@hvdijk hvdijk merged commit 3ec9f74 into llvm:main Feb 12, 2025
8 checks passed
@hvdijk hvdijk deleted the dibuilder-insertposition branch February 12, 2025 17:39
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder mlir-nvidia-gcc7 running on mlir-nvidia while building clang,llvm at step 7 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/116/builds/10165

Here is the relevant piece of the build log for the reference
Step 7 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/omptarget-debug-var-1.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-translate -mlir-to-llvmir /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir | /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-translate -mlir-to-llvmir /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# .---command stderr------------
# | /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir:60:11: error: CHECK: expected string not found in input
# | // CHECK: !DILocalVariable(name: "dyn_ptr", arg: 1, scope: ![[SP]]{{.*}}flags: DIFlagArtificial)
# |           ^
# | <stdin>:93:291: note: scanning from here
# | !17 = distinct !DISubprogram(name: "__omp_offloading_2e_1c5a0e_test_l43", linkageName: "__omp_offloading_2e_1c5a0e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                   ^
# | <stdin>:93:291: note: with "SP" equal to "17"
# | !17 = distinct !DISubprogram(name: "__omp_offloading_2e_1c5a0e_test_l43", linkageName: "__omp_offloading_2e_1c5a0e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                   ^
# | <stdin>:100:7: note: possible intended match here
# | !24 = !DILocalVariable(name: "arr", arg: 3, scope: !17, file: !3, line: 4, type: !5)
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            88: !12 = !{null} 
# |            89: !13 = !DILocation(line: 32, column: 10, scope: !10) 
# |            90: !14 = !DILocation(line: 33, column: 10, scope: !10) 
# |            91: !15 = !DILocation(line: 43, column: 5, scope: !10) 
# |            92: !16 = !DILocation(line: 49, column: 5, scope: !10) 
# |            93: !17 = distinct !DISubprogram(name: "__omp_offloading_2e_1c5a0e_test_l43", linkageName: "__omp_offloading_2e_1c5a0e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2) 
# | check:60'0                                                                                                                                                                                                                                                                                                       X error: no match found
# | check:60'1                                                                                                                                                                                                                                                                                                         with "SP" equal to "17"
# |            94: !18 = !DISubroutineType(types: !19) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            95: !19 = !{} 
# | check:60'0     ~~~~~~~~~~
# |            96: !20 = !DILocation(line: 43, column: 5, scope: !17) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            97: !21 = !DILocalVariable(name: "x", arg: 2, scope: !17, file: !3, line: 12, type: !22) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            98: !22 = !DIBasicType(name: "real", size: 32, encoding: DW_ATE_float) 
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder mlir-rocm-mi200 running on mi200-buildbot while building clang,llvm at step 7 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/177/builds/12901

Here is the relevant piece of the build log for the reference
Step 7 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/omptarget-debug-var-1.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/mlir-translate -mlir-to-llvmir /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir | /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/FileCheck /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/mlir-translate -mlir-to-llvmir /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/FileCheck /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# .---command stderr------------
# | /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir:60:11: error: CHECK: expected string not found in input
# | // CHECK: !DILocalVariable(name: "dyn_ptr", arg: 1, scope: ![[SP]]{{.*}}flags: DIFlagArtificial)
# |           ^
# | <stdin>:93:293: note: scanning from here
# | !17 = distinct !DISubprogram(name: "__omp_offloading_802_9032d5_test_l43", linkageName: "__omp_offloading_802_9032d5_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                     ^
# | <stdin>:93:293: note: with "SP" equal to "17"
# | !17 = distinct !DISubprogram(name: "__omp_offloading_802_9032d5_test_l43", linkageName: "__omp_offloading_802_9032d5_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                     ^
# | <stdin>:100:7: note: possible intended match here
# | !24 = !DILocalVariable(name: "arr", arg: 3, scope: !17, file: !3, line: 4, type: !5)
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            88: !12 = !{null} 
# |            89: !13 = !DILocation(line: 32, column: 10, scope: !10) 
# |            90: !14 = !DILocation(line: 33, column: 10, scope: !10) 
# |            91: !15 = !DILocation(line: 43, column: 5, scope: !10) 
# |            92: !16 = !DILocation(line: 49, column: 5, scope: !10) 
# |            93: !17 = distinct !DISubprogram(name: "__omp_offloading_802_9032d5_test_l43", linkageName: "__omp_offloading_802_9032d5_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2) 
# | check:60'0                                                                                                                                                                                                                                                                                                         X error: no match found
# | check:60'1                                                                                                                                                                                                                                                                                                           with "SP" equal to "17"
# |            94: !18 = !DISubroutineType(types: !19) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            95: !19 = !{} 
# | check:60'0     ~~~~~~~~~~
# |            96: !20 = !DILocation(line: 43, column: 5, scope: !17) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            97: !21 = !DILocalVariable(name: "x", arg: 2, scope: !17, file: !3, line: 12, type: !22) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            98: !22 = !DIBasicType(name: "real", size: 32, encoding: DW_ATE_float) 
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building clang,llvm at step 6 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/14702

Here is the relevant piece of the build log for the reference
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/omptarget-debug-var-1.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/mlir-translate -mlir-to-llvmir /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir | /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/mlir-translate -mlir-to-llvmir /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# .---command stderr------------
# | /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir:60:11: error: CHECK: expected string not found in input
# | // CHECK: !DILocalVariable(name: "dyn_ptr", arg: 1, scope: ![[SP]]{{.*}}flags: DIFlagArtificial)
# |           ^
# | <stdin>:93:297: note: scanning from here
# | !17 = distinct !DISubprogram(name: "__omp_offloading_900_60f3a81e_test_l43", linkageName: "__omp_offloading_900_60f3a81e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                         ^
# | <stdin>:93:297: note: with "SP" equal to "17"
# | !17 = distinct !DISubprogram(name: "__omp_offloading_900_60f3a81e_test_l43", linkageName: "__omp_offloading_900_60f3a81e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                         ^
# | <stdin>:100:7: note: possible intended match here
# | !24 = !DILocalVariable(name: "arr", arg: 3, scope: !17, file: !3, line: 4, type: !5)
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            88: !12 = !{null} 
# |            89: !13 = !DILocation(line: 32, column: 10, scope: !10) 
# |            90: !14 = !DILocation(line: 33, column: 10, scope: !10) 
# |            91: !15 = !DILocation(line: 43, column: 5, scope: !10) 
# |            92: !16 = !DILocation(line: 49, column: 5, scope: !10) 
# |            93: !17 = distinct !DISubprogram(name: "__omp_offloading_900_60f3a81e_test_l43", linkageName: "__omp_offloading_900_60f3a81e_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2) 
# | check:60'0                                                                                                                                                                                                                                                                                                             X error: no match found
# | check:60'1                                                                                                                                                                                                                                                                                                               with "SP" equal to "17"
# |            94: !18 = !DISubroutineType(types: !19) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            95: !19 = !{} 
# | check:60'0     ~~~~~~~~~~
# |            96: !20 = !DILocation(line: 43, column: 5, scope: !17) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            97: !21 = !DILocalVariable(name: "x", arg: 2, scope: !17, file: !3, line: 12, type: !22) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            98: !22 = !DIBasicType(name: "real", size: 32, encoding: DW_ATE_float) 
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/17955

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/1/41' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3425083-1-41.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=41 GTEST_SHARD_INDEX=1 /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 2 of 41.
[==========] Running 4 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenACCTest
[ RUN      ] OpenACCTest.ClauseHelpers
[       OK ] OpenACCTest.ClauseHelpers (0 ms)
[----------] 1 test from OpenACCTest (0 ms total)

[----------] 2 tests from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.CriticalDirective
[       OK ] OpenMPIRBuilderTest.CriticalDirective (0 ms)
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
 #0 0x000059ae94d04e90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x659e90)
 #1 0x000059ae94d0276f llvm::sys::RunSignalHandlers() (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x65776f)
 #2 0x000059ae94d028ba SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007d5edfa76520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007d5edfaca9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007d5edfaca9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007d5edfaca9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007d5edfa76476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007d5edfa5c7f3 abort ./stdlib/abort.c:81:7
 #9 0x00007d5edfa5c71b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007d5edfa6de96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000059ae94b44e33 (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x499e33)
#12 0x000059ae94b30df5 llvm::LLVMContext::~LLVMContext() (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x485df5)
#13 0x000059ae947e67c9 (anonymous namespace)::OpenMPIRBuilderTest_TargetRegionDeviceSPMD_Test::~OpenMPIRBuilderTest_TargetRegionDeviceSPMD_Test() OpenMPIRBuilderTest.cpp:0:0
#14 0x000059ae94d6034c testing::TestInfo::Run() (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x6b534c)
#15 0x000059ae94d60a31 testing::TestSuite::Run() (.part.0) gtest-all.cc:0:0
#16 0x000059ae94d6ba5a testing::internal::UnitTestImpl::RunAllTests() (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x6c0a5a)
#17 0x000059ae94d54e9f testing::UnitTest::Run() (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x6a9e9f)
#18 0x000059ae9473e59a main (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0x9359a)
#19 0x00007d5edfa5dd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#20 0x00007d5edfa5de40 call_init ./csu/../csu/libc-start.c:128:20
#21 0x00007d5edfa5de40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#22 0x000059ae947a4f35 _start (/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/Frontend/./LLVMFrontendTests+0xf9f35)

...

hvdijk added a commit that referenced this pull request Feb 12, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b1 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/13112

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/1/41' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/ml-opt-devrel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-452761-1-41.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=41 GTEST_SHARD_INDEX=1 /b/ml-opt-devrel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 2 of 41.
[==========] Running 4 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenACCTest
[ RUN      ] OpenACCTest.ClauseHelpers
[       OK ] OpenACCTest.ClauseHelpers (0 ms)
[----------] 1 test from OpenACCTest (0 ms total)

[----------] 2 tests from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.CriticalDirective
[       OK ] OpenMPIRBuilderTest.CriticalDirective (0 ms)
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x0000558623f1d928
1  LLVMFrontendTests 0x0000558623f1b215
2  libpthread.so.0   0x00007f29aad2c140
3  libc.so.6         0x00007f29aa82dd51 gsignal + 321
4  libc.so.6         0x00007f29aa817537 abort + 291
5  libc.so.6         0x00007f29aa81740f
6  libc.so.6         0x00007f29aa8266d2
7  LLVMFrontendTests 0x0000558623d697af
8  LLVMFrontendTests 0x0000558623d55f01
9  LLVMFrontendTests 0x0000558623a2b8e5
10 LLVMFrontendTests 0x0000558623f71f7c
11 LLVMFrontendTests 0x0000558623f726a7
12 LLVMFrontendTests 0x0000558623f7fd26
13 LLVMFrontendTests 0x0000558623f6964c
14 LLVMFrontendTests 0x000055862397ec76
15 libc.so.6         0x00007f29aa818d7a __libc_start_main + 234
16 LLVMFrontendTests 0x00005586239eb33a

--
exit: -6
--
shard JSON output does not exist: /b/ml-opt-devrel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-452761-1-41.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-rel-x86-64 running on ml-opt-rel-x86-64-b2 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/13063

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/1/41' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/ml-opt-rel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-1153031-1-41.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=41 GTEST_SHARD_INDEX=1 /b/ml-opt-rel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 2 of 41.
[==========] Running 4 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenACCTest
[ RUN      ] OpenACCTest.ClauseHelpers
[       OK ] OpenACCTest.ClauseHelpers (0 ms)
[----------] 1 test from OpenACCTest (0 ms total)

[----------] 2 tests from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.CriticalDirective
[       OK ] OpenMPIRBuilderTest.CriticalDirective (0 ms)
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x000055a87c74ba78
1  LLVMFrontendTests 0x000055a87c749365
2  libpthread.so.0   0x00007f308dbf1140
3  libc.so.6         0x00007f308d6f2d51 gsignal + 321
4  libc.so.6         0x00007f308d6dc537 abort + 291
5  libc.so.6         0x00007f308d6dc40f
6  libc.so.6         0x00007f308d6eb6d2
7  LLVMFrontendTests 0x000055a87c597b6f
8  LLVMFrontendTests 0x000055a87c5842c1
9  LLVMFrontendTests 0x000055a87c259ca5
10 LLVMFrontendTests 0x000055a87c7a00cc
11 LLVMFrontendTests 0x000055a87c7a07f7
12 LLVMFrontendTests 0x000055a87c7ade76
13 LLVMFrontendTests 0x000055a87c79779c
14 LLVMFrontendTests 0x000055a87c1af186
15 libc.so.6         0x00007f308d6ddd7a __libc_start_main + 234
16 LLVMFrontendTests 0x000055a87c2196fa

--
exit: -6
--
shard JSON output does not exist: /b/ml-opt-rel-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-1153031-1-41.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder mlir-nvidia running on mlir-nvidia while building clang,llvm at step 7 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/138/builds/10230

Here is the relevant piece of the build log for the reference
Step 7 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/omptarget-debug-var-1.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/mlir-translate -mlir-to-llvmir /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir | /vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/mlir-translate -mlir-to-llvmir /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# executed command: /vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# .---command stderr------------
# | /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir:60:11: error: CHECK: expected string not found in input
# | // CHECK: !DILocalVariable(name: "dyn_ptr", arg: 1, scope: ![[SP]]{{.*}}flags: DIFlagArtificial)
# |           ^
# | <stdin>:93:291: note: scanning from here
# | !17 = distinct !DISubprogram(name: "__omp_offloading_2e_152832_test_l43", linkageName: "__omp_offloading_2e_152832_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                   ^
# | <stdin>:93:291: note: with "SP" equal to "17"
# | !17 = distinct !DISubprogram(name: "__omp_offloading_2e_152832_test_l43", linkageName: "__omp_offloading_2e_152832_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2)
# |                                                                                                                                                                                                                                                                                                   ^
# | <stdin>:100:7: note: possible intended match here
# | !24 = !DILocalVariable(name: "arr", arg: 3, scope: !17, file: !3, line: 4, type: !5)
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/Target/LLVMIR/omptarget-debug-var-1.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            88: !12 = !{null} 
# |            89: !13 = !DILocation(line: 32, column: 10, scope: !10) 
# |            90: !14 = !DILocation(line: 33, column: 10, scope: !10) 
# |            91: !15 = !DILocation(line: 43, column: 5, scope: !10) 
# |            92: !16 = !DILocation(line: 49, column: 5, scope: !10) 
# |            93: !17 = distinct !DISubprogram(name: "__omp_offloading_2e_152832_test_l43", linkageName: "__omp_offloading_2e_152832_test_l43", scope: null, file: !3, line: 43, type: !18, scopeLine: 43, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2) 
# | check:60'0                                                                                                                                                                                                                                                                                                       X error: no match found
# | check:60'1                                                                                                                                                                                                                                                                                                         with "SP" equal to "17"
# |            94: !18 = !DISubroutineType(types: !19) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            95: !19 = !{} 
# | check:60'0     ~~~~~~~~~~
# |            96: !20 = !DILocation(line: 43, column: 5, scope: !17) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            97: !21 = !DILocalVariable(name: "x", arg: 2, scope: !17, file: !3, line: 12, type: !22) 
# | check:60'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            98: !22 = !DIBasicType(name: "real", size: 32, encoding: DW_ATE_float) 
...

@hvdijk
Copy link
Contributor Author

hvdijk commented Feb 12, 2025

The buildbot failures look like something conflicted with changes that have since gone into LLVM. I have reverted the change for now and will check what is going on and update.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-win-fast running on as-builder-3 while building clang,llvm at step 7 "test-build-unified-tree-check-llvm-unit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/2/builds/16997

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm-unit) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests.exe/0/81' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\Frontend\.\LLVMFrontendTests.exe-LLVM-Unit-4748-0-81.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=81 GTEST_SHARD_INDEX=0 C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\Frontend\.\LLVMFrontendTests.exe
--

Script:
--
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\Frontend\.\LLVMFrontendTests.exe --gtest_filter=OpenMPIRBuilderTest.TargetRegionDevice
--
Basic Block has trailing DbgRecords!
label %entry
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\Frontend\OpenMPIRBuilderTest.cpp(6436): error: Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false


C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\Frontend\OpenMPIRBuilderTest.cpp:6436
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/14543

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/6/11' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-60260-6-11.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=11 GTEST_SHARD_INDEX=6 /Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 7 of 11.
[==========] Running 15 tests from 6 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPContextTest
[ RUN      ] OpenMPContextTest.ApplicabilityAllTraits
[       OK ] OpenMPContextTest.ApplicabilityAllTraits (0 ms)
[----------] 1 test from OpenMPContextTest (0 ms total)

[----------] 8 tests from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.ParallelIfCond
[       OK ] OpenMPIRBuilderTest.ParallelIfCond (0 ms)
[ RUN      ] OpenMPIRBuilderTest.ApplySimdCustomAligned
[       OK ] OpenMPIRBuilderTest.ApplySimdCustomAligned (0 ms)
[ RUN      ] OpenMPIRBuilderTest.DynamicWorkShareLoopOrdered
[       OK ] OpenMPIRBuilderTest.DynamicWorkShareLoopOrdered (0 ms)
[ RUN      ] OpenMPIRBuilderTest.SingleDirectiveCopyPrivate
[       OK ] OpenMPIRBuilderTest.SingleDirectiveCopyPrivate (0 ms)
[ RUN      ] OpenMPIRBuilderTest.CreateTeams
[       OK ] OpenMPIRBuilderTest.CreateTeams (0 ms)
[ RUN      ] OpenMPIRBuilderTest.CreateSectionsNoWait
[       OK ] OpenMPIRBuilderTest.CreateSectionsNoWait (0 ms)
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

Assertion failed: (TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"), function ~LLVMContextImpl, file LLVMContextImpl.cpp, line 50.
 #0 0x0000000104babac8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x10052bac8)
 #1 0x0000000104baa040 llvm::sys::RunSignalHandlers() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x10052a040)
 #2 0x0000000104bac2c4 SignalHandler(int, __siginfo*, void*) (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x10052c2c4)
 #3 0x0000000185882584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584)
 #4 0x0000000185851c20 (/usr/lib/system/libsystem_pthread.dylib+0x180449c20)
 #5 0x000000018575ea30 (/usr/lib/system/libsystem_c.dylib+0x180356a30)
 #6 0x000000018575dd20 (/usr/lib/system/libsystem_c.dylib+0x180355d20)
 #7 0x0000000104e99620 llvm::ConstantUniqueMap<llvm::ConstantExpr>::freeConstants() (.cold.1) (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x100819620)
 #8 0x0000000104a32bd4 llvm::LLVMContextImpl::~LLVMContextImpl() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x1003b2bd4)
 #9 0x0000000104a2bea4 llvm::LLVMContext::~LLVMContext() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x1003abea4)
#10 0x0000000104742dc0 (anonymous namespace)::OpenMPIRBuilderTest_TargetRegionDeviceSPMD_Test::~OpenMPIRBuilderTest_TargetRegionDeviceSPMD_Test() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x1000c2dc0)
#11 0x0000000104bf329c testing::TestInfo::Run() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x10057329c)
#12 0x0000000104bf3e88 testing::TestSuite::Run() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x100573e88)
#13 0x0000000104c02338 testing::internal::UnitTestImpl::RunAllTests() (/Users/buildbot/buildbot-root/aarch64-darwin/build/unittests/Frontend/LLVMFrontendTests+0x100582338)
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder clang-armv8-quick running on linaro-clang-armv8-quick while building clang,llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/11762

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/84/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2206097-84-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=84 /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 85 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.ConstantAllocaRaise
Basic Block has trailing DbgRecords!
label %entry
../llvm/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6816: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: ../llvm/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
#0 0x00ac7df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/unittests/Frontend/./LLVMFrontendTests+0x5cedf8)
#1 0x00ac5b98 llvm::sys::RunSignalHandlers() (/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/unittests/Frontend/./LLVMFrontendTests+0x5ccb98)
#2 0x00ac8840 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0xf78dd6f0 __default_rt_sa_restorer ./signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:80:0
#4 0xf78cdb06 ./csu/../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47:0
#5 0xf790d292 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0xf78dc840 gsignal ./signal/../sysdeps/posix/raise.c:27:6

--
exit: -6
--
shard JSON output does not exist: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2206097-84-161.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b2 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/13269

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/2/41' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/ml-opt-dev-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3757608-2-41.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=41 GTEST_SHARD_INDEX=2 /b/ml-opt-dev-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 3 of 41.
[==========] Running 4 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenACCTest
[ RUN      ] OpenACCTest.AllowedClause
[       OK ] OpenACCTest.AllowedClause (0 ms)
[----------] 1 test from OpenACCTest (0 ms total)

[----------] 2 tests from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.OrderedDirectiveDependSource
[       OK ] OpenMPIRBuilderTest.OrderedDirectiveDependSource (0 ms)
[ RUN      ] OpenMPIRBuilderTest.ConstantAllocaRaise
Basic Block has trailing DbgRecords!
label %entry
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6816: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x000055dc3f199e08
1  LLVMFrontendTests 0x000055dc3f1976f5
2  libpthread.so.0   0x00007f3c2aadd140
3  libc.so.6         0x00007f3c2a5ded51 gsignal + 321
4  libc.so.6         0x00007f3c2a5c8537 abort + 291
5  libc.so.6         0x00007f3c2a5c840f
6  libc.so.6         0x00007f3c2a5d76d2
7  LLVMFrontendTests 0x000055dc3efe5c8f
8  LLVMFrontendTests 0x000055dc3efd23e1
9  LLVMFrontendTests 0x000055dc3eca6745
10 LLVMFrontendTests 0x000055dc3f1ee45c
11 LLVMFrontendTests 0x000055dc3f1eeb87
12 LLVMFrontendTests 0x000055dc3f1fc206
13 LLVMFrontendTests 0x000055dc3f1e5b2c
14 LLVMFrontendTests 0x000055dc3ebfac26
15 libc.so.6         0x00007f3c2a5c9d7a __libc_start_main + 234
16 LLVMFrontendTests 0x000055dc3ec6781a

--
exit: -6
--
shard JSON output does not exist: /b/ml-opt-dev-x86-64-b1/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3757608-2-41.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building clang,llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/12905

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/83/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2668642-83-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=83 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 84 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.so.21.0git     0x0000767ef6368a90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 240
1  libLLVMSupport.so.21.0git     0x0000767ef6365e8f llvm::sys::RunSignalHandlers() + 47
2  libLLVMSupport.so.21.0git     0x0000767ef6365fda
3  libc.so.6                     0x0000767ef5a42520
4  libc.so.6                     0x0000767ef5a969fc pthread_kill + 300
5  libc.so.6                     0x0000767ef5a42476 raise + 22
6  libc.so.6                     0x0000767ef5a287f3 abort + 211
7  libc.so.6                     0x0000767ef5a2871b
8  libc.so.6                     0x0000767ef5a39e96
9  libLLVMCore.so.21.0git        0x0000767ef67bb163
10 libLLVMCore.so.21.0git        0x0000767ef67a58b5 llvm::LLVMContext::~LLVMContext() + 21
11 LLVMFrontendTests             0x00005b5b728d42f9
12 libllvm_gtest.so.21.0git      0x0000767ef64805bc testing::TestInfo::Run() + 396
13 libllvm_gtest.so.21.0git      0x0000767ef6480ca1
14 libllvm_gtest.so.21.0git      0x0000767ef648feea testing::internal::UnitTestImpl::RunAllTests() + 2842
15 libllvm_gtest.so.21.0git      0x0000767ef6470bbf testing::UnitTest::Run() + 143
16 libllvm_gtest_main.so.21.0git 0x0000767ef767abba main + 106
17 libc.so.6                     0x0000767ef5a29d90
18 libc.so.6                     0x0000767ef5a29e40 __libc_start_main + 128
19 LLVMFrontendTests             0x00005b5b72892a65

--
exit: -6
--
shard JSON output does not exist: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2668642-83-161.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building clang,llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/12902

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/84/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2849394-84-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=84 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 85 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.ConstantAllocaRaise
Basic Block has trailing DbgRecords!
label %entry
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6816: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.so.21.0git     0x000070456b899a90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 240
1  libLLVMSupport.so.21.0git     0x000070456b896e8f llvm::sys::RunSignalHandlers() + 47
2  libLLVMSupport.so.21.0git     0x000070456b896fda
3  libc.so.6                     0x000070456b042520
4  libc.so.6                     0x000070456b0969fc pthread_kill + 300
5  libc.so.6                     0x000070456b042476 raise + 22
6  libc.so.6                     0x000070456b0287f3 abort + 211
7  libc.so.6                     0x000070456b02871b
8  libc.so.6                     0x000070456b039e96
9  libLLVMCore.so.21.0git        0x000070456bcec163
10 libLLVMCore.so.21.0git        0x000070456bcd68b5 llvm::LLVMContext::~LLVMContext() + 21
11 LLVMFrontendTests             0x00005d60cd346869
12 libllvm_gtest.so.21.0git      0x000070456b9b15bc testing::TestInfo::Run() + 396
13 libllvm_gtest.so.21.0git      0x000070456b9b1ca1
14 libllvm_gtest.so.21.0git      0x000070456b9c0eea testing::internal::UnitTestImpl::RunAllTests() + 2842
15 libllvm_gtest.so.21.0git      0x000070456b9a1bbf testing::UnitTest::Run() + 143
16 libllvm_gtest_main.so.21.0git 0x000070456cbabbba main + 106
17 libc.so.6                     0x000070456b029d90
18 libc.so.6                     0x000070456b029e40 __libc_start_main + 128
19 LLVMFrontendTests             0x00005d60cd304a55

--
exit: -6
--
shard JSON output does not exist: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-2849394-84-161.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/11262

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/3/81' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-4017663-3-81.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=81 GTEST_SHARD_INDEX=3 /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 4 of 81.
[==========] Running 2 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPContextTest
[ RUN      ] OpenMPContextTest.RoundTripAndAssociation
[       OK ] OpenMPContextTest.RoundTripAndAssociation (0 ms)
[----------] 1 test from OpenMPContextTest (0 ms total)

[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.ConstantAllocaRaise
Basic Block has trailing DbgRecords!
label %entry
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6816: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x000055c09b022e40
1  LLVMFrontendTests 0x000055c09b02071f
2  LLVMFrontendTests 0x000055c09b02086a
3  libc.so.6         0x00007ff721333520
4  libc.so.6         0x00007ff7213879fc pthread_kill + 300
5  libc.so.6         0x00007ff721333476 raise + 22
6  libc.so.6         0x00007ff7213197f3 abort + 211
7  libc.so.6         0x00007ff72131971b
8  libc.so.6         0x00007ff72132ae96
9  LLVMFrontendTests 0x000055c09ae63053
10 LLVMFrontendTests 0x000055c09ae4f025
11 LLVMFrontendTests 0x000055c09ab056b9
12 LLVMFrontendTests 0x000055c09b07e06c
13 LLVMFrontendTests 0x000055c09b07e751
14 LLVMFrontendTests 0x000055c09b08971a
15 LLVMFrontendTests 0x000055c09b072bff
16 LLVMFrontendTests 0x000055c09aa5cfba
17 libc.so.6         0x00007ff72131ad90
18 libc.so.6         0x00007ff72131ae40 __libc_start_main + 128
19 LLVMFrontendTests 0x000055c09aac3955

--
exit: -6
--
shard JSON output does not exist: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-4017663-3-81.json
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang,llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/22689

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/3/81' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/build/buildbot/premerge-monolithic-linux/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-304124-3-81.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=81 GTEST_SHARD_INDEX=3 /build/buildbot/premerge-monolithic-linux/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 4 of 81.
[==========] Running 2 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPContextTest
[ RUN      ] OpenMPContextTest.RoundTripAndAssociation
[       OK ] OpenMPContextTest.RoundTripAndAssociation (0 ms)
[----------] 1 test from OpenMPContextTest (0 ms total)

[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.ConstantAllocaRaise
Basic Block has trailing DbgRecords!
label %entry
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6816: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x00005647010de5c8
1  LLVMFrontendTests 0x00005647010dc50c
2  LLVMFrontendTests 0x00005647010ded91
3  libc.so.6         0x00007d6c2c3f2520
4  libc.so.6         0x00007d6c2c4469fc pthread_kill + 300
5  libc.so.6         0x00007d6c2c3f2476 raise + 22
6  libc.so.6         0x00007d6c2c3d87f3 abort + 211
7  libc.so.6         0x00007d6c2c3d871b
8  libc.so.6         0x00007d6c2c3e9e96
9  LLVMFrontendTests 0x0000564700f1b9e5
10 LLVMFrontendTests 0x0000564700f12161
11 LLVMFrontendTests 0x0000564700c5ec0d
12 LLVMFrontendTests 0x000056470112c50e
13 LLVMFrontendTests 0x000056470112d0a3
14 LLVMFrontendTests 0x000056470113de78
15 LLVMFrontendTests 0x000056470113d30c
16 LLVMFrontendTests 0x000056470111769c
17 libc.so.6         0x00007d6c2c3d9d90
18 libc.so.6         0x00007d6c2c3d9e40 __libc_start_main + 128
19 LLVMFrontendTests 0x0000564700b947c5

--
exit: -6
--
shard JSON output does not exist: /build/buildbot/premerge-monolithic-linux/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-304124-3-81.json
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-x86_64-debian-dylib running on gribozavr4 while building clang,llvm at step 7 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/19454

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/83/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/1/llvm-x86_64-debian-dylib/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3509997-83-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=83 /b/1/llvm-x86_64-debian-dylib/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 84 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDeviceSPMD
Basic Block has trailing DbgRecords!
label %entry
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6695: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.so.21.0git 0x00007f7188ac5007 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  libLLVM.so.21.0git 0x00007f7188ac2a8c llvm::sys::RunSignalHandlers() + 188
2  libLLVM.so.21.0git 0x00007f7188ac56da
3  libpthread.so.0    0x00007f7192197140
4  libc.so.6          0x00007f7187678d51 gsignal + 321
5  libc.so.6          0x00007f7187662537 abort + 291
6  libc.so.6          0x00007f718766240f
7  libc.so.6          0x00007f71876716d2
8  libLLVM.so.21.0git 0x00007f7188c82ea0 llvm::LLVMContextImpl::~LLVMContextImpl() + 33248
9  libLLVM.so.21.0git 0x00007f7188c78921 llvm::LLVMContext::~LLVMContext() + 17
10 LLVMFrontendTests  0x00000000004eb03d
11 LLVMFrontendTests  0x000000000055a1ea
12 LLVMFrontendTests  0x000000000055af56
13 LLVMFrontendTests  0x000000000056e0dd
14 LLVMFrontendTests  0x000000000056d43a
15 LLVMFrontendTests  0x00000000005451bc
16 libc.so.6          0x00007f7187663d7a __libc_start_main + 234
17 LLVMFrontendTests  0x000000000041da7a

--
exit: -6
--
shard JSON output does not exist: /b/1/llvm-x86_64-debian-dylib/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3509997-83-161.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/18511

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/81/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/1/clang-x86_64-debian-fast/llvm.obj/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3721442-81-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=81 /b/1/clang-x86_64-debian-fast/llvm.obj/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 82 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDevice
Basic Block has trailing DbgRecords!
label %entry
/b/1/clang-x86_64-debian-fast/llvm.src/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6436: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/1/clang-x86_64-debian-fast/llvm.src/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x00000000009d6eb7
1  LLVMFrontendTests 0x00000000009d4d9c
2  LLVMFrontendTests 0x00000000009d76ba
3  libpthread.so.0   0x00007f45b1f7c140
4  libc.so.6         0x00007f45b1a90d51 gsignal + 321
5  libc.so.6         0x00007f45b1a7a537 abort + 291
6  libc.so.6         0x00007f45b1a7a40f
7  libc.so.6         0x00007f45b1a896d2
8  LLVMFrontendTests 0x0000000000837140
9  LLVMFrontendTests 0x000000000082d0a1
10 LLVMFrontendTests 0x00000000005800fd
11 LLVMFrontendTests 0x0000000000a2549a
12 LLVMFrontendTests 0x0000000000a26206
13 LLVMFrontendTests 0x0000000000a3928d
14 LLVMFrontendTests 0x0000000000a385ea
15 LLVMFrontendTests 0x0000000000a10a9c
16 libc.so.6         0x00007f45b1a7bd7a __libc_start_main + 234
17 LLVMFrontendTests 0x00000000004ba0da

--
exit: -6
--
shard JSON output does not exist: /b/1/clang-x86_64-debian-fast/llvm.obj/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-3721442-81-161.json
********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-expensive-checks-debian running on gribozavr4 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/13685

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Frontend/./LLVMFrontendTests/81/161' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/1/llvm-clang-x86_64-expensive-checks-debian/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-519351-81-161.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=161 GTEST_SHARD_INDEX=81 /b/1/llvm-clang-x86_64-expensive-checks-debian/build/unittests/Frontend/./LLVMFrontendTests
--

Note: This is test shard 82 of 161.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpenMPIRBuilderTest
[ RUN      ] OpenMPIRBuilderTest.TargetRegionDevice
Basic Block has trailing DbgRecords!
label %entry
/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:6436: Failure
Value of: verifyModule(*M, &errs())
  Actual: true
Expected: false

LLVMFrontendTests: /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/lib/IR/LLVMContextImpl.cpp:50: llvm::LLVMContextImpl::~LLVMContextImpl(): Assertion `TrailingDbgRecords.empty() && "DbgRecords in blocks not cleaned"' failed.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  LLVMFrontendTests 0x00000000009ddf57
1  LLVMFrontendTests 0x00000000009dbe3c
2  LLVMFrontendTests 0x00000000009de75a
3  libpthread.so.0   0x00007f5f77408140
4  libc.so.6         0x00007f5f76f1cd51 gsignal + 321
5  libc.so.6         0x00007f5f76f06537 abort + 291
6  libc.so.6         0x00007f5f76f0640f
7  libc.so.6         0x00007f5f76f156d2
8  LLVMFrontendTests 0x0000000000839e30
9  LLVMFrontendTests 0x000000000082fd91
10 LLVMFrontendTests 0x000000000058107d
11 LLVMFrontendTests 0x0000000000a2c8ea
12 LLVMFrontendTests 0x0000000000a2d656
13 LLVMFrontendTests 0x0000000000a406dd
14 LLVMFrontendTests 0x0000000000a3fa3a
15 LLVMFrontendTests 0x0000000000a17eec
16 libc.so.6         0x00007f5f76f07d7a __libc_start_main + 234
17 LLVMFrontendTests 0x00000000004bb05a

--
exit: -6
--
shard JSON output does not exist: /b/1/llvm-clang-x86_64-expensive-checks-debian/build/unittests/Frontend/./LLVMFrontendTests-LLVM-Unit-519351-81-161.json
********************


flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
…26059)

After llvm#124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…26059)

After llvm#124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…26059)

After llvm#124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category coroutines C++20 coroutines debuginfo llvm:ir llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants