From 459475020aeff15d0f886ab99c59d66b744d3e17 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Wed, 11 Jun 2025 16:35:55 +0100 Subject: Reapply 76197ea6f91f after removing an assertion Specifically this is the assertion in BasicBlock.cpp. Now that we're not examining or setting that flag consistently (because it'll be deleted in about an hour) there's no need to keep this assertion. Original commit title: [DebugInfo][RemoveDIs] Remove some debug intrinsic-only codepaths (#143451) --- llvm/lib/IR/DIBuilder.cpp | 97 ++++++++++------------------------------------- 1 file changed, 20 insertions(+), 77 deletions(-) (limited to 'llvm/lib/IR/DIBuilder.cpp') diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 5e5ff22..1484c54 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -1047,36 +1047,13 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val, LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID)); assert(Link && "Linked instruction must have DIAssign metadata attached"); - if (M.IsNewDbgInfoFormat) { - DbgVariableRecord *DVR = DbgVariableRecord::createDVRAssign( - Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL); - // Insert after LinkedInstr. - BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator()); - NextIt.setHeadBit(true); - insertDbgVariableRecord(DVR, NextIt); - return DVR; - } - - LLVMContext &Ctx = LinkedInstr->getContext(); - Module *M = LinkedInstr->getModule(); - if (!AssignFn) - AssignFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign); - - std::array Args = { - MetadataAsValue::get(Ctx, ValueAsMetadata::get(Val)), - MetadataAsValue::get(Ctx, SrcVar), - MetadataAsValue::get(Ctx, ValExpr), - MetadataAsValue::get(Ctx, Link), - MetadataAsValue::get(Ctx, ValueAsMetadata::get(Addr)), - MetadataAsValue::get(Ctx, AddrExpr), - }; - - IRBuilder<> B(Ctx); - B.SetCurrentDebugLocation(DL); - - auto *DVI = cast(B.CreateCall(AssignFn, Args)); - DVI->insertAfter(LinkedInstr->getIterator()); - return DVI; + DbgVariableRecord *DVR = DbgVariableRecord::createDVRAssign( + Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL); + // Insert after LinkedInstr. + BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator()); + NextIt.setHeadBit(true); + insertDbgVariableRecord(DVR, NextIt); + return DVR; } /// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics. @@ -1101,18 +1078,10 @@ DbgInstPtr DIBuilder::insertDbgValueIntrinsic(llvm::Value *Val, DIExpression *Expr, const DILocation *DL, InsertPosition InsertPt) { - if (M.IsNewDbgInfoFormat) { - DbgVariableRecord *DVR = - DbgVariableRecord::createDbgVariableRecord(Val, VarInfo, Expr, DL); - insertDbgVariableRecord(DVR, InsertPt); - return DVR; - } - - if (!ValueFn) - ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value); - auto *DVI = insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertPt); - cast(DVI)->setTailCall(); - return DVI; + DbgVariableRecord *DVR = + DbgVariableRecord::createDbgVariableRecord(Val, VarInfo, Expr, DL); + insertDbgVariableRecord(DVR, InsertPt); + return DVR; } DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, @@ -1124,25 +1093,10 @@ DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, VarInfo->getScope()->getSubprogram() && "Expected matching subprograms"); - if (M.IsNewDbgInfoFormat) { - DbgVariableRecord *DVR = - DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL); - insertDbgVariableRecord(DVR, InsertPt); - return DVR; - } - - if (!DeclareFn) - DeclareFn = getDeclareIntrin(M); - - trackIfUnresolved(VarInfo); - trackIfUnresolved(Expr); - Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage), - MetadataAsValue::get(VMContext, VarInfo), - MetadataAsValue::get(VMContext, Expr)}; - - IRBuilder<> B(DL->getContext()); - initIRBuilder(B, DL, InsertPt); - return B.CreateCall(DeclareFn, Args); + DbgVariableRecord *DVR = + DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL); + insertDbgVariableRecord(DVR, InsertPt); + return DVR; } void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR, @@ -1191,23 +1145,12 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, "Expected matching subprograms"); trackIfUnresolved(LabelInfo); - if (M.IsNewDbgInfoFormat) { - DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL); - if (InsertPt.isValid()) { - auto *BB = InsertPt.getBasicBlock(); - BB->insertDbgRecordBefore(DLR, InsertPt); - } - return DLR; + DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL); + if (InsertPt.isValid()) { + auto *BB = InsertPt.getBasicBlock(); + BB->insertDbgRecordBefore(DLR, InsertPt); } - - if (!LabelFn) - LabelFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_label); - - Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)}; - - IRBuilder<> B(DL->getContext()); - initIRBuilder(B, DL, InsertPt); - return B.CreateCall(LabelFn, Args); + return DLR; } void DIBuilder::replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder) { -- cgit v1.1