From 25c66b1ca09c3e9683a5fb8b419b21964a92db65 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Sun, 10 Mar 2024 21:34:19 +0000 Subject: [PATCH] Remove C-API changes --- llvm/docs/RemoveDIsDebugInfo.md | 16 --- llvm/include/llvm-c/Core.h | 8 -- llvm/include/llvm-c/DebugInfo.h | 88 +-------------- llvm/include/llvm-c/Types.h | 5 - .../include/llvm/IR/DebugProgramInstruction.h | 2 - llvm/lib/IR/DebugInfo.cpp | 101 ++++++------------ llvm/tools/llvm-c-test/debuginfo.c | 44 +++----- 7 files changed, 47 insertions(+), 217 deletions(-) diff --git a/llvm/docs/RemoveDIsDebugInfo.md b/llvm/docs/RemoveDIsDebugInfo.md index 3755181f7a02e..a0577678e20fc 100644 --- a/llvm/docs/RemoveDIsDebugInfo.md +++ b/llvm/docs/RemoveDIsDebugInfo.md @@ -30,22 +30,6 @@ There are two significant changes to be aware of. Firstly, we're adding a single The second matter is that if you transfer sequences of instructions from one place to another manually, i.e. repeatedly using `moveBefore` where you might have used `splice`, then you should instead use the method `moveBeforePreserving`. `moveBeforePreserving` will transfer debug info records with the instruction they're attached to. This is something that happens automatically today -- if you use `moveBefore` on every element of an instruction sequence, then debug intrinsics will be moved in the normal course of your code, but we lose this behaviour with non-instruction debug info. -# C-API changes - -``` -LLVMDIBuilderInsertDeclareBefore # Changed - Inserts a non-instruction debug record. -LLVMDIBuilderInsertDeclareAtEnd # Changed - Inserts a non-instruction debug record. -LLVMDIBuilderInsertDbgValueBefore # Changed - Inserts a non-instruction debug record. -LLVMDIBuilderInsertDbgValueAtEnd # Changed - Inserts a non-instruction debug record. - -LLVMIsNewDbgInfoFormat # New - Returns true if the module is in the new non-instruction mode. Will be deprecated in future. -LLVMDIBuilderInsertDeclareIntrinsicBefore # New - Old behaviour of the changed functions above, i.e., insert a dbg intrinsic call. Will be deprecated in future. -LLVMDIBuilderInsertDeclareIntrinsicAtEnd # New - Old behaviour of the changed functions above, i.e., insert a dbg intrinsic call. Will be deprecated in future. -LLVMDIBuilderInsertDbgValueIntrinsicBefore # New - Old behaviour of the changed functions above, i.e., insert a dbg intrinsic call. Will be deprecated in future. -LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # New - Old behaviour of the changed functions above, i.e., insert a dbg intrinsic call. Will be deprecated in future. -``` - - # Anything else? Not really, but here's an "old vs new" comparison of how to do certain things and quickstart for how this "new" debug info is structured. diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index 1ea4b59b85706..7cfe4dc4f775f 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -744,14 +744,6 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); */ void LLVMDisposeModule(LLVMModuleRef M); -/** - * Returns true if the module is in the new debug info mode which uses - * non-instruction debug records instead of debug intrinsics for variable - * location tracking. - * See See https://llvm.org/docs/RemoveDIsDebugInfo.html. - */ -LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M); - /** * Obtain the identifier of a module. * diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h index 6dd36f8dedec4..ed863cff378fc 100644 --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -1249,10 +1249,6 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl( LLVMMetadataRef Decl, uint32_t AlignInBits); /** - * Soon to be deprecated. - * Only use in "old debug mode" (LLVMIsNewDbgFormat() is false). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * * Insert a new llvm.dbg.declare intrinsic call before the given instruction. * \param Builder The DIBuilder. * \param Storage The storage of the variable to declare. @@ -1261,31 +1257,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl( * \param DebugLoc Debug info location. * \param Instr Instruction acting as a location for the new intrinsic. */ -LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore( - LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr); -/** - * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * - * Insert a Declare DbgRecord before the given instruction. - * \param Builder The DIBuilder. - * \param Storage The storage of the variable to declare. - * \param VarInfo The variable's debug info descriptor. - * \param Expr A complex location expression for the variable. - * \param DebugLoc Debug info location. - * \param Instr Instruction acting as a location for the new record. - */ -LLVMDbgRecordRef +LLVMValueRef LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr); /** - * Soon to be deprecated. - * Only use in "old debug mode" (LLVMIsNewDbgFormat() is false). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * * Insert a new llvm.dbg.declare intrinsic call at the end of the given basic * block. If the basic block has a terminator instruction, the intrinsic is * inserted before that terminator instruction. @@ -1296,47 +1273,11 @@ LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, * \param DebugLoc Debug info location. * \param Block Basic block acting as a location for the new intrinsic. */ -LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd( - LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block); -/** - * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * - * Insert a Declare DbgRecord at the end of the given basic block. If the basic - * block has a terminator instruction, the record is inserted before that - * terminator instruction. - * \param Builder The DIBuilder. - * \param Storage The storage of the variable to declare. - * \param VarInfo The variable's debug info descriptor. - * \param Expr A complex location expression for the variable. - * \param DebugLoc Debug info location. - * \param Block Basic block acting as a location for the new record. - */ -LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd( +LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block); /** - * Soon to be deprecated. - * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * - * Insert a new llvm.dbg.value intrinsic call before the given instruction. - * \param Builder The DIBuilder. - * \param Val The value of the variable. - * \param VarInfo The variable's debug info descriptor. - * \param Expr A complex location expression for the variable. - * \param DebugLoc Debug info location. - * \param Instr Instruction acting as a location for the new intrinsic. - */ -LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore( - LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr); -/** - * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * * Insert a new llvm.dbg.value intrinsic call before the given instruction. * \param Builder The DIBuilder. * \param Val The value of the variable. @@ -1345,33 +1286,12 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore( * \param DebugLoc Debug info location. * \param Instr Instruction acting as a location for the new intrinsic. */ -LLVMDbgRecordRef +LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr); /** - * Soon to be deprecated. - * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * - * Insert a new llvm.dbg.value intrinsic call at the end of the given basic - * block. If the basic block has a terminator instruction, the intrinsic is - * inserted before that terminator instruction. - * \param Builder The DIBuilder. - * \param Val The value of the variable. - * \param VarInfo The variable's debug info descriptor. - * \param Expr A complex location expression for the variable. - * \param DebugLoc Debug info location. - * \param Block Basic block acting as a location for the new intrinsic. - */ -LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd( - LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block); -/** - * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true). - * See https://llvm.org/docs/RemoveDIsDebugInfo.html - * * Insert a new llvm.dbg.value intrinsic call at the end of the given basic * block. If the basic block has a terminator instruction, the intrinsic is * inserted before that terminator instruction. @@ -1382,7 +1302,7 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd( * \param DebugLoc Debug info location. * \param Block Basic block acting as a location for the new intrinsic. */ -LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd( +LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd( LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block); diff --git a/llvm/include/llvm-c/Types.h b/llvm/include/llvm-c/Types.h index 4681500ef9da3..d5474d986309f 100644 --- a/llvm/include/llvm-c/Types.h +++ b/llvm/include/llvm-c/Types.h @@ -169,11 +169,6 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef; */ typedef struct LLVMOpaqueBinary *LLVMBinaryRef; -/** - * @see llvm::DbgRecord - */ -typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef; - /** * @} */ diff --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h index 960489dc52b12..a8faf415a3ea8 100644 --- a/llvm/include/llvm/IR/DebugProgramInstruction.h +++ b/llvm/include/llvm/IR/DebugProgramInstruction.h @@ -643,8 +643,6 @@ getDbgValueRange(DPMarker *DbgMarker) { return DbgMarker->getDbgValueRange(); } -DEFINE_ISA_CONVERSION_FUNCTIONS(DbgRecord, LLVMDbgRecordRef); - } // namespace llvm #endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 91c5499eac4e8..68fd244e25697 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1659,90 +1659,51 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl( unwrapDI(Decl), nullptr, AlignInBits)); } -LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore( - LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) { - return wrap( - unwrap(Builder) - ->insertDeclare(unwrap(Storage), unwrap(VarInfo), - unwrap(Expr), unwrap(DL), - unwrap(Instr)) - .get()); -} -LLVMDbgRecordRef +LLVMValueRef LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) { - return wrap( - unwrap(Builder) - ->insertDeclare(unwrap(Storage), unwrap(VarInfo), - unwrap(Expr), unwrap(DL), - unwrap(Instr)) - .get()); -} - -LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd( - LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) { - return wrap(unwrap(Builder) - ->insertDeclare(unwrap(Storage), - unwrap(VarInfo), - unwrap(Expr), - unwrap(DL), unwrap(Block)) - .get()); -} -LLVMDbgRecordRef + DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare( + unwrap(Storage), unwrap(VarInfo), + unwrap(Expr), unwrap(DL), + unwrap(Instr)); + assert(isa(DbgInst) && + "Inserted a DbgRecord into function using old debug info mode"); + return wrap(cast(DbgInst)); +} + +LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) { - return wrap(unwrap(Builder) - ->insertDeclare(unwrap(Storage), - unwrap(VarInfo), - unwrap(Expr), - unwrap(DL), unwrap(Block)) - .get()); + DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare( + unwrap(Storage), unwrap(VarInfo), + unwrap(Expr), unwrap(DL), unwrap(Block)); + assert(isa(DbgInst) && + "Inserted a DbgRecord into function using old debug info mode"); + return wrap(cast(DbgInst)); } -LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore( +LLVMValueRef LLVMDIBuilderInsertDbgValueBefore( LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) { - return wrap(unwrap(Builder) - ->insertDbgValueIntrinsic( - unwrap(Val), unwrap(VarInfo), - unwrap(Expr), unwrap(DebugLoc), - unwrap(Instr)) - .get()); -} -LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore( - LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) { - return wrap(unwrap(Builder) - ->insertDbgValueIntrinsic( - unwrap(Val), unwrap(VarInfo), - unwrap(Expr), unwrap(DebugLoc), - unwrap(Instr)) - .get()); + DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic( + unwrap(Val), unwrap(VarInfo), unwrap(Expr), + unwrap(DebugLoc), unwrap(Instr)); + assert(isa(DbgInst) && + "Inserted a DbgRecord into function using old debug info mode"); + return wrap(cast(DbgInst)); } -LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd( - LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, - LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) { - return wrap(unwrap(Builder) - ->insertDbgValueIntrinsic( - unwrap(Val), unwrap(VarInfo), - unwrap(Expr), unwrap(DebugLoc), - unwrap(Block)) - .get()); -} -LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd( +LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd( LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) { - return wrap(unwrap(Builder) - ->insertDbgValueIntrinsic( - unwrap(Val), unwrap(VarInfo), - unwrap(Expr), unwrap(DebugLoc), - unwrap(Block)) - .get()); + DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic( + unwrap(Val), unwrap(VarInfo), unwrap(Expr), + unwrap(DebugLoc), unwrap(Block)); + assert(isa(DbgInst) && + "Inserted a DbgRecord into function using old debug info mode"); + return wrap(cast(DbgInst)); } LLVMMetadataRef LLVMDIBuilderCreateAutoVariable( diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c index 4f4571d3292ff..a3e41be12e95d 100644 --- a/llvm/tools/llvm-c-test/debuginfo.c +++ b/llvm/tools/llvm-c-test/debuginfo.c @@ -135,38 +135,21 @@ int llvm_test_dibuilder(void) { LLVMMetadataRef FooParamVar1 = LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File, 42, Int64Ty, true, 0); - if (LLVMIsNewDbgInfoFormat(M)) - LLVMDIBuilderInsertDeclareAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1, - FooParamExpression, FooParamLocation, FooEntryBlock); - else - LLVMDIBuilderInsertDeclareIntrinsicAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1, - FooParamExpression, FooParamLocation, FooEntryBlock); + LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false), + FooParamVar1, FooParamExpression, + FooParamLocation, FooEntryBlock); LLVMMetadataRef FooParamVar2 = LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "b", 1, 2, File, 42, Int64Ty, true, 0); - - if (LLVMIsNewDbgInfoFormat(M)) - LLVMDIBuilderInsertDeclareAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2, - FooParamExpression, FooParamLocation, FooEntryBlock); - else - LLVMDIBuilderInsertDeclareIntrinsicAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2, - FooParamExpression, FooParamLocation, FooEntryBlock); - + LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false), + FooParamVar2, FooParamExpression, + FooParamLocation, FooEntryBlock); LLVMMetadataRef FooParamVar3 = LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File, 42, VectorTy, true, 0); - if (LLVMIsNewDbgInfoFormat(M)) - LLVMDIBuilderInsertDeclareAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3, - FooParamExpression, FooParamLocation, FooEntryBlock); - else - LLVMDIBuilderInsertDeclareIntrinsicAtEnd( - DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3, - FooParamExpression, FooParamLocation, FooEntryBlock); + LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false), + FooParamVar3, FooParamExpression, + FooParamLocation, FooEntryBlock); LLVMSetSubprogram(FooFunction, FunctionMetadata); @@ -183,12 +166,9 @@ int llvm_test_dibuilder(void) { LLVMValueRef FooVal1 = LLVMConstInt(LLVMInt64Type(), 0, false); LLVMMetadataRef FooVarValueExpr = LLVMDIBuilderCreateConstantValueExpression(DIB, 0); - if (LLVMIsNewDbgInfoFormat(M)) - LLVMDIBuilderInsertDbgValueAtEnd(DIB, FooVal1, FooVar1, FooVarValueExpr, - FooVarsLocation, FooVarBlock); - else - LLVMDIBuilderInsertDbgValueIntrinsicAtEnd( - DIB, FooVal1, FooVar1, FooVarValueExpr, FooVarsLocation, FooVarBlock); + + LLVMDIBuilderInsertDbgValueAtEnd(DIB, FooVal1, FooVar1, FooVarValueExpr, + FooVarsLocation, FooVarBlock); LLVMMetadataRef MacroFile = LLVMDIBuilderCreateTempMacroFile(DIB, NULL, 0, File);