diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -47,7 +47,6 @@ Function *DeclareFn; ///< llvm.dbg.declare Function *ValueFn; ///< llvm.dbg.value Function *LabelFn; ///< llvm.dbg.label - Function *AddrFn; ///< llvm.dbg.addr Function *AssignFn; ///< llvm.dbg.assign SmallVector AllEnumTypes; @@ -102,12 +101,6 @@ DIExpression *Expr, const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore); - /// Internal helper for insertDbgAddrIntrinsic. - Instruction * - insertDbgAddrIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo, - DIExpression *Expr, const DILocation *DL, - BasicBlock *InsertBB, Instruction *InsertBefore); - public: /// Construct a builder for a module. /// @@ -986,30 +979,6 @@ const DILocation *DL, Instruction *InsertBefore); - /// Insert a new llvm.dbg.addr intrinsic call. - /// \param Addr llvm::Value of the address - /// \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. - Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr, - DILocalVariable *VarInfo, - DIExpression *Expr, - const DILocation *DL, - BasicBlock *InsertAtEnd); - - /// Insert a new llvm.dbg.addr intrinsic call. - /// \param Addr llvm::Value of the address. - /// \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. - Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr, - DILocalVariable *VarInfo, - DIExpression *Expr, - const DILocation *DL, - Instruction *InsertBefore); - /// Replace the vtable holder in the given type. /// /// If this creates a self reference, it may orphan some unresolved cycles diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h --- a/llvm/include/llvm/IR/DebugInfo.h +++ b/llvm/include/llvm/IR/DebugInfo.h @@ -35,13 +35,8 @@ class Instruction; class Module; -/// Finds all intrinsics declaring local variables as living in the memory that -/// 'V' points to. This may include a mix of dbg.declare and -/// dbg.addr intrinsics. -TinyPtrVector FindDbgAddrUses(Value *V); - -/// Like \c FindDbgAddrUses, but only returns dbg.declare intrinsics, not -/// dbg.addr. +/// Finds dbg.declare intrinsics declaring local variables as living in the +/// memory that 'V' points to. TinyPtrVector FindDbgDeclareUses(Value *V); /// Finds the llvm.dbg.value intrinsics describing a value. diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2843,9 +2843,9 @@ /// non-variadic form and not considering the debug operands. /// \p FirstExpr is the DIExpression for the first debug value. /// \p FirstIndirect should be true if the first debug value is indirect; in - /// IR this should be true for dbg.declare and dbg.addr intrinsics and false - /// for dbg.values, and in MIR this should be true only for DBG_VALUE - /// instructions whose second operand is an immediate value. + /// IR this should be true for dbg.declare intrinsics and false for + /// dbg.values, and in MIR this should be true only for DBG_VALUE instructions + /// whose second operand is an immediate value. /// \p SecondExpr and \p SecondIndirect have the same meaning as the prior /// arguments, but apply to the second debug value. static bool isEqualExpression(const DIExpression *FirstExpr, diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h --- a/llvm/include/llvm/IR/IntrinsicInst.h +++ b/llvm/include/llvm/IR/IntrinsicInst.h @@ -154,7 +154,6 @@ switch (ID) { case Intrinsic::dbg_declare: case Intrinsic::dbg_value: - case Intrinsic::dbg_addr: case Intrinsic::dbg_label: case Intrinsic::dbg_assign: return true; @@ -259,12 +258,11 @@ bool hasArgList() const { return isa(getRawLocation()); } - /// Does this describe the address of a local variable. True for dbg.addr and - /// dbg.declare, but not dbg.value, which describes its value, or dbg.assign, - /// which describes a combination of the variable's value and address. + /// Does this describe the address of a local variable. True for dbg.declare, + /// but not dbg.value, which describes its value, or dbg.assign, which + /// describes a combination of the variable's value and address. bool isAddressOfVariable() const { - return getIntrinsicID() != Intrinsic::dbg_value && - getIntrinsicID() != Intrinsic::dbg_assign; + return getIntrinsicID() == Intrinsic::dbg_declare; } void setKillLocation() { @@ -327,7 +325,6 @@ switch (I->getIntrinsicID()) { case Intrinsic::dbg_declare: case Intrinsic::dbg_value: - case Intrinsic::dbg_addr: case Intrinsic::dbg_assign: return true; default: @@ -365,25 +362,6 @@ /// @} }; -/// This represents the llvm.dbg.addr instruction. -class DbgAddrIntrinsic : public DbgVariableIntrinsic { -public: - Value *getAddress() const { - assert(getNumVariableLocationOps() == 1 && - "dbg.addr must have exactly 1 location operand."); - return getVariableLocationOp(0); - } - - /// \name Casting methods - /// @{ - static bool classof(const IntrinsicInst *I) { - return I->getIntrinsicID() == Intrinsic::dbg_addr; - } - static bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - /// This represents the llvm.dbg.value instruction. class DbgValueInst : public DbgVariableIntrinsic { public: diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -1002,10 +1002,6 @@ [llvm_metadata_ty, llvm_metadata_ty, llvm_metadata_ty]>; - def int_dbg_addr : DefaultAttrsIntrinsic<[], - [llvm_metadata_ty, - llvm_metadata_ty, - llvm_metadata_ty]>; def int_dbg_assign : DefaultAttrsIntrinsic<[], [llvm_metadata_ty, llvm_metadata_ty, diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -23,14 +23,9 @@ using namespace llvm; using namespace llvm::dwarf; -static cl::opt - UseDbgAddr("use-dbg-addr", - llvm::cl::desc("Use llvm.dbg.addr for all local variables"), - cl::init(false), cl::Hidden); - DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU) : M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr), - ValueFn(nullptr), LabelFn(nullptr), AddrFn(nullptr), AssignFn(nullptr), + ValueFn(nullptr), LabelFn(nullptr), AssignFn(nullptr), AllowUnresolvedNodes(AllowUnresolvedNodes) { if (CUNode) { if (const auto &ETs = CUNode->getEnumTypes()) @@ -1022,24 +1017,6 @@ return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr); } -Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V, - DILocalVariable *VarInfo, - DIExpression *Expr, - const DILocation *DL, - Instruction *InsertBefore) { - return insertDbgAddrIntrinsic( - V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr, - InsertBefore); -} - -Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V, - DILocalVariable *VarInfo, - DIExpression *Expr, - const DILocation *DL, - BasicBlock *InsertAtEnd) { - return insertDbgAddrIntrinsic(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, @@ -1057,8 +1034,7 @@ } static Function *getDeclareIntrin(Module &M) { - return Intrinsic::getDeclaration(&M, UseDbgAddr ? Intrinsic::dbg_addr - : Intrinsic::dbg_declare); + return Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); } Instruction *DIBuilder::insertDbgValueIntrinsic( @@ -1070,15 +1046,6 @@ InsertBefore); } -Instruction *DIBuilder::insertDbgAddrIntrinsic( - llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, - const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) { - if (!AddrFn) - AddrFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_addr); - return insertDbgIntrinsic(AddrFn, Val, VarInfo, Expr, DL, InsertBB, - InsertBefore); -} - Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertBB, diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -43,10 +43,7 @@ using namespace llvm::at; using namespace llvm::dwarf; -/// Finds all intrinsics declaring local variables as living in the memory that -/// 'V' points to. This may include a mix of dbg.declare and -/// dbg.addr intrinsics. -TinyPtrVector llvm::FindDbgAddrUses(Value *V) { +TinyPtrVector llvm::FindDbgDeclareUses(Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. if (!V->isUsedByMetadata()) @@ -58,24 +55,15 @@ if (!MDV) return {}; - TinyPtrVector Declares; + TinyPtrVector Declares; for (User *U : MDV->users()) { - if (auto *DII = dyn_cast(U)) - if (DII->isAddressOfVariable()) - Declares.push_back(DII); + if (auto *DDI = dyn_cast(U)) + Declares.push_back(DDI); } return Declares; } -TinyPtrVector llvm::FindDbgDeclareUses(Value *V) { - TinyPtrVector DDIs; - for (DbgVariableIntrinsic *DVI : FindDbgAddrUses(V)) - if (auto *DDI = dyn_cast(DVI)) - DDIs.push_back(DDI); - return DDIs; -} - void llvm::findDbgValues(SmallVectorImpl &DbgValues, Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. @@ -801,7 +789,6 @@ Changed = true; } }; - RemoveUses("llvm.dbg.addr"); RemoveUses("llvm.dbg.declare"); RemoveUses("llvm.dbg.label"); RemoveUses("llvm.dbg.value"); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -5116,9 +5116,6 @@ "invalid llvm.dbg.declare intrinsic call 1", Call); visitDbgIntrinsic("declare", cast(Call)); break; - case Intrinsic::dbg_addr: // llvm.dbg.addr - visitDbgIntrinsic("addr", cast(Call)); - break; case Intrinsic::dbg_value: // llvm.dbg.value visitDbgIntrinsic("value", cast(Call)); break; diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp --- a/llvm/unittests/IR/BasicBlockTest.cpp +++ b/llvm/unittests/IR/BasicBlockTest.cpp @@ -106,7 +106,6 @@ Argument *V = new Argument(Type::getInt32Ty(Ctx)); Function *F = Function::Create(FT, Function::ExternalLinkage, "", M); - Function *DbgAddr = Intrinsic::getDeclaration(M, Intrinsic::dbg_addr); Function *DbgDeclare = Intrinsic::getDeclaration(M, Intrinsic::dbg_declare); Function *DbgValue = Intrinsic::getDeclaration(M, Intrinsic::dbg_value); Value *DIV = MetadataAsValue::get(Ctx, (Metadata *)nullptr); @@ -122,7 +121,6 @@ Instruction *MulInst = cast(Builder1.CreateMul(AddInst, V)); Builder1.CreateCall(DbgDeclare, Args); Instruction *SubInst = cast(Builder1.CreateSub(MulInst, V)); - Builder1.CreateCall(DbgAddr, Args); SmallVector Exp = {Var, AddInst, MulInst, SubInst}; CHECK_ITERATORS(BB1->instructionsWithoutDebug(), Exp); diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -321,71 +321,6 @@ EXPECT_FALSE(E2); } -TEST(DIBuilder, createDbgAddr) { - LLVMContext C; - std::unique_ptr M = parseIR(C, R"( - define void @f() !dbg !6 { - %a = alloca i16, align 8 - ;; It is important that we put the debug marker on the return. - ;; We take advantage of that to conjure up a debug loc without - ;; having to synthesize one programatically. - ret void, !dbg !11 - } - declare void @llvm.dbg.value(metadata, metadata, metadata) #0 - attributes #0 = { nounwind readnone speculatable willreturn } - - !llvm.dbg.cu = !{!0} - !llvm.module.flags = !{!5} - - !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) - !1 = !DIFile(filename: "t.ll", directory: "/") - !2 = !{} - !5 = !{i32 2, !"Debug Info Version", i32 3} - !6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) - !7 = !DISubroutineType(types: !2) - !8 = !{!9} - !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10) - !10 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_unsigned) - !11 = !DILocation(line: 1, column: 1, scope: !6) -)"); - auto *F = M->getFunction("f"); - auto *EntryBlock = &F->getEntryBlock(); - - auto *CU = - cast(M->getNamedMetadata("llvm.dbg.cu")->getOperand(0)); - auto *Alloca = &*EntryBlock->begin(); - auto *Ret = EntryBlock->getTerminator(); - - auto *SP = cast(F->getMetadata(LLVMContext::MD_dbg)); - auto *File = SP->getFile(); - std::string Name = "myName"; - const auto *Loc = Ret->getDebugLoc().get(); - - IRBuilder<> Builder(EntryBlock); - DIBuilder DIB(*M, true, CU); - DIType *DT = DIB.createBasicType("ty16", 16, dwarf::DW_ATE_unsigned); - - DILocalVariable *LocalVar = - DIB.createAutoVariable(SP, Name, File, 5 /*line*/, DT, - /*AlwaysPreserve=*/true); - - auto *Inst = DIB.insertDbgAddrIntrinsic(Alloca, LocalVar, - DIB.createExpression(), Loc, Ret); - - DIB.finalize(); - - EXPECT_EQ(Inst->getDebugLoc().get(), Loc); - - auto *MD0 = cast(Inst->getOperand(0))->getMetadata(); - auto *MD0Local = cast(MD0); - EXPECT_EQ(MD0Local->getValue(), Alloca); - auto *MD1 = cast(Inst->getOperand(1))->getMetadata(); - EXPECT_EQ(MD1->getMetadataID(), Metadata::MetadataKind::DILocalVariableKind); - auto *MD2 = cast(Inst->getOperand(2))->getMetadata(); - auto *MDExp = cast(MD2); - EXPECT_EQ(MDExp->getNumElements(), 0u); -} - TEST(DbgAssignIntrinsicTest, replaceVariableLocationOp) { LLVMContext C; std::unique_ptr M = parseIR(C, R"(