Skip to content

Commit

Permalink
Remove C-API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OCHyams committed Mar 10, 2024
1 parent edecd14 commit 25c66b1
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 217 deletions.
16 changes: 0 additions & 16 deletions llvm/docs/RemoveDIsDebugInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions llvm/include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
88 changes: 4 additions & 84 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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);

Expand Down
5 changes: 0 additions & 5 deletions llvm/include/llvm-c/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef;
*/
typedef struct LLVMOpaqueBinary *LLVMBinaryRef;

/**
* @see llvm::DbgRecord
*/
typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef;

/**
* @}
*/
Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/IR/DebugProgramInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,6 @@ getDbgValueRange(DPMarker *DbgMarker) {
return DbgMarker->getDbgValueRange();
}

DEFINE_ISA_CONVERSION_FUNCTIONS(DbgRecord, LLVMDbgRecordRef);

} // namespace llvm

#endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
101 changes: 31 additions & 70 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,90 +1659,51 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unwrapDI<MDNode>(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<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr))
.get<Instruction *>());
}
LLVMDbgRecordRef
LLVMValueRef
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMValueRef Instr) {
return wrap(
unwrap(Builder)
->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr))
.get<DbgRecord *>());
}

LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
return wrap(unwrap(Builder)
->insertDeclare(unwrap(Storage),
unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr),
unwrap<DILocation>(DL), unwrap(Block))
.get<Instruction *>());
}
LLVMDbgRecordRef
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr));
assert(isa<Instruction *>(DbgInst) &&
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}

LLVMValueRef
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
return wrap(unwrap(Builder)
->insertDeclare(unwrap(Storage),
unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr),
unwrap<DILocation>(DL), unwrap(Block))
.get<DbgRecord *>());
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
assert(isa<Instruction *>(DbgInst) &&
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(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<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap<Instruction>(Instr))
.get<Instruction *>());
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
return wrap(unwrap(Builder)
->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap<Instruction>(Instr))
.get<DbgRecord *>());
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
assert(isa<Instruction *>(DbgInst) &&
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}

LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
return wrap(unwrap(Builder)
->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap(Block))
.get<Instruction *>());
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
return wrap(unwrap(Builder)
->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
unwrap(Block))
.get<DbgRecord *>());
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap(Block));
assert(isa<Instruction *>(DbgInst) &&
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}

LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(
Expand Down
44 changes: 12 additions & 32 deletions llvm/tools/llvm-c-test/debuginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 25c66b1

Please sign in to comment.