Skip to content

Commit f6cf3fa

Browse files
committed
[RemoveDIs] Update DIBuilder C API with DbgRecord functions [2/2]
Follow on from llvm#84915 which adds the DbgRecord function variants. Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd
1 parent d56110f commit f6cf3fa

File tree

4 files changed

+65
-56
lines changed

4 files changed

+65
-56
lines changed

llvm/docs/RemoveDIsDebugInfo.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ New functions (all to be deprecated)
4040
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
4141
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
4242
43-
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
43+
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
4444
LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
4545
LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
4646
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
4747
48-
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
48+
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
4949
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above.
5050
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above.
5151
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above.
52+
53+
Existing functions (behaviour change)
54+
-------------------------------------
55+
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
56+
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
57+
LLVMDIBuilderInsertDbgValueBefore # Same as above.
58+
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
5259
```
5360

5461
# Anything else?

llvm/include/llvm-c/DebugInfo.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,15 +1249,15 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
12491249
LLVMMetadataRef Decl, uint32_t AlignInBits);
12501250

12511251
/*
1252-
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
1252+
* Insert a new Declare DbgRecord before the given instruction.
12531253
* \param Builder The DIBuilder.
12541254
* \param Storage The storage of the variable to declare.
12551255
* \param VarInfo The variable's debug info descriptor.
12561256
* \param Expr A complex location expression for the variable.
12571257
* \param DebugLoc Debug info location.
12581258
* \param Instr Instruction acting as a location for the new intrinsic.
12591259
*/
1260-
LLVMValueRef
1260+
LLVMDbgRecordRef
12611261
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
12621262
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
12631263
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
@@ -1295,17 +1295,17 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
12951295
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
12961296

12971297
/**
1298-
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
1299-
* block. If the basic block has a terminator instruction, the intrinsic is
1300-
* inserted before that terminator instruction.
1298+
* Insert a new Declare DbgRecord at the end of the given basic block. If the
1299+
* basic block has a terminator instruction, the intrinsic is inserted before
1300+
* that terminator instruction.
13011301
* \param Builder The DIBuilder.
13021302
* \param Storage The storage of the variable to declare.
13031303
* \param VarInfo The variable's debug info descriptor.
13041304
* \param Expr A complex location expression for the variable.
13051305
* \param DebugLoc Debug info location.
13061306
* \param Block Basic block acting as a location for the new intrinsic.
13071307
*/
1308-
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
1308+
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd(
13091309
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
13101310
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
13111311
/**
@@ -1346,15 +1346,15 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
13461346
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
13471347

13481348
/**
1349-
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
1349+
* Insert a new Value DbgRecord before the given instruction.
13501350
* \param Builder The DIBuilder.
13511351
* \param Val The value of the variable.
13521352
* \param VarInfo The variable's debug info descriptor.
13531353
* \param Expr A complex location expression for the variable.
13541354
* \param DebugLoc Debug info location.
13551355
* \param Instr Instruction acting as a location for the new intrinsic.
13561356
*/
1357-
LLVMValueRef
1357+
LLVMDbgRecordRef
13581358
LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
13591359
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
13601360
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
@@ -1392,17 +1392,17 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
13921392
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
13931393

13941394
/**
1395-
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
1396-
* block. If the basic block has a terminator instruction, the intrinsic is
1397-
* inserted before that terminator instruction.
1395+
* Insert a new Value DbgRecord at the end of the given basic block. If the
1396+
* basic block has a terminator instruction, the intrinsic is inserted before
1397+
* that terminator instruction.
13981398
* \param Builder The DIBuilder.
13991399
* \param Val The value of the variable.
14001400
* \param VarInfo The variable's debug info descriptor.
14011401
* \param Expr A complex location expression for the variable.
14021402
* \param DebugLoc Debug info location.
14031403
* \param Block Basic block acting as a location for the new intrinsic.
14041404
*/
1405-
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
1405+
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
14061406
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
14071407
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
14081408
/**

llvm/lib/IR/DebugInfo.cpp

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,12 +1659,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
16591659
unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
16601660
}
16611661

1662-
LLVMValueRef
1662+
LLVMDbgRecordRef
16631663
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
16641664
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
16651665
LLVMMetadataRef DL, LLVMValueRef Instr) {
1666-
return LLVMDIBuilderInsertDeclareIntrinsicBefore(Builder, Storage, VarInfo,
1667-
Expr, DL, Instr);
1666+
return LLVMDIBuilderInsertDeclareRecordBefore(Builder, Storage, VarInfo, Expr,
1667+
DL, Instr);
16681668
}
16691669
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
16701670
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
@@ -1680,20 +1680,21 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
16801680
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
16811681
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
16821682
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) {
1683-
return wrap(
1684-
unwrap(Builder)
1685-
->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1686-
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1687-
unwrap<Instruction>(Instr))
1688-
.get<DbgRecord *>());
1683+
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
1684+
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1685+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1686+
unwrap<Instruction>(Instr));
1687+
assert(isa<DbgRecord *>(DbgInst) &&
1688+
"Inserted a debug intrinsic into function using new debug info mode");
1689+
return wrap(cast<DbgRecord *>(DbgInst));
16891690
}
16901691

1691-
LLVMValueRef
1692+
LLVMDbgRecordRef
16921693
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
16931694
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
16941695
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
1695-
return LLVMDIBuilderInsertDeclareIntrinsicAtEnd(Builder, Storage, VarInfo,
1696-
Expr, DL, Block);
1696+
return LLVMDIBuilderInsertDeclareRecordAtEnd(Builder, Storage, VarInfo, Expr,
1697+
DL, Block);
16971698
}
16981699
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
16991700
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
@@ -1708,19 +1709,19 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
17081709
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
17091710
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
17101711
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
1711-
return wrap(unwrap(Builder)
1712-
->insertDeclare(unwrap(Storage),
1713-
unwrap<DILocalVariable>(VarInfo),
1714-
unwrap<DIExpression>(Expr),
1715-
unwrap<DILocation>(DL), unwrap(Block))
1716-
.get<DbgRecord *>());
1712+
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
1713+
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1714+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
1715+
assert(isa<DbgRecord *>(DbgInst) &&
1716+
"Inserted a debug intrinsic into function using new debug info mode");
1717+
return wrap(cast<DbgRecord *>(DbgInst));
17171718
}
17181719

1719-
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(
1720+
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore(
17201721
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
17211722
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
1722-
return LLVMDIBuilderInsertDbgValueIntrinsicBefore(Builder, Val, VarInfo, Expr,
1723-
DebugLoc, Instr);
1723+
return LLVMDIBuilderInsertDbgValueRecordBefore(Builder, Val, VarInfo, Expr,
1724+
DebugLoc, Instr);
17241725
}
17251726
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
17261727
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
@@ -1735,19 +1736,19 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
17351736
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
17361737
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
17371738
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
1738-
return wrap(unwrap(Builder)
1739-
->insertDbgValueIntrinsic(
1740-
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1741-
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1742-
unwrap<Instruction>(Instr))
1743-
.get<DbgRecord *>());
1739+
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
1740+
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1741+
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
1742+
assert(isa<DbgRecord *>(DbgInst) &&
1743+
"Inserted a debug intrinsic into function using new debug info mode");
1744+
return wrap(cast<DbgRecord *>(DbgInst));
17441745
}
17451746

1746-
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
1747+
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
17471748
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
17481749
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
1749-
return LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(Builder, Val, VarInfo, Expr,
1750-
DebugLoc, Block);
1750+
return LLVMDIBuilderInsertDbgValueRecordAtEnd(Builder, Val, VarInfo, Expr,
1751+
DebugLoc, Block);
17511752
}
17521753
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
17531754
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
@@ -1762,12 +1763,12 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
17621763
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
17631764
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
17641765
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
1765-
return wrap(unwrap(Builder)
1766-
->insertDbgValueIntrinsic(
1767-
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1768-
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1769-
unwrap(Block))
1770-
.get<DbgRecord *>());
1766+
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
1767+
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1768+
unwrap<DILocation>(DebugLoc), unwrap(Block));
1769+
assert(isa<DbgRecord *>(DbgInst) &&
1770+
"Inserted a DbgRecord into function using old debug info mode");
1771+
return wrap(cast<DbgRecord *>(DbgInst));
17711772
}
17721773

17731774
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(

llvm/tools/llvm-c-test/debuginfo.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,36 +136,37 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
136136
LLVMMetadataRef FooParamVar1 =
137137
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File,
138138
42, Int64Ty, true, 0);
139+
139140
if (LLVMIsNewDbgInfoFormat(M))
140-
LLVMDIBuilderInsertDeclareRecordAtEnd(
141+
LLVMDIBuilderInsertDeclareAtEnd(
141142
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
142143
FooParamExpression, FooParamLocation, FooEntryBlock);
143144
else
144-
LLVMDIBuilderInsertDeclareAtEnd(
145+
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
145146
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
146147
FooParamExpression, FooParamLocation, FooEntryBlock);
147148
LLVMMetadataRef FooParamVar2 =
148149
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "b", 1, 2, File,
149150
42, Int64Ty, true, 0);
150151

151152
if (LLVMIsNewDbgInfoFormat(M))
152-
LLVMDIBuilderInsertDeclareRecordAtEnd(
153+
LLVMDIBuilderInsertDeclareAtEnd(
153154
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
154155
FooParamExpression, FooParamLocation, FooEntryBlock);
155156
else
156-
LLVMDIBuilderInsertDeclareAtEnd(
157+
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
157158
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
158159
FooParamExpression, FooParamLocation, FooEntryBlock);
159160

160161
LLVMMetadataRef FooParamVar3 =
161162
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File,
162163
42, VectorTy, true, 0);
163164
if (LLVMIsNewDbgInfoFormat(M))
164-
LLVMDIBuilderInsertDeclareRecordAtEnd(
165+
LLVMDIBuilderInsertDeclareAtEnd(
165166
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
166167
FooParamExpression, FooParamLocation, FooEntryBlock);
167168
else
168-
LLVMDIBuilderInsertDeclareAtEnd(
169+
LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
169170
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
170171
FooParamExpression, FooParamLocation, FooEntryBlock);
171172

0 commit comments

Comments
 (0)