Skip to content

Commit 8b03c20

Browse files
committed
Revert "C-API approach #1 - return a union"
This reverts commit 8b8cddb.
1 parent 2e69a99 commit 8b03c20

File tree

4 files changed

+70
-75
lines changed

4 files changed

+70
-75
lines changed

llvm/include/llvm-c/DebugInfo.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,10 +1257,9 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
12571257
* \param DebugLoc Debug info location.
12581258
* \param Instr Instruction acting as a location for the new intrinsic.
12591259
*/
1260-
LLVMDbgInstRef
1261-
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
1262-
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1263-
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1260+
LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
1261+
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1262+
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
12641263

12651264
/**
12661265
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
@@ -1273,7 +1272,7 @@ LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
12731272
* \param DebugLoc Debug info location.
12741273
* \param Block Basic block acting as a location for the new intrinsic.
12751274
*/
1276-
LLVMDbgInstRef LLVMDIBuilderInsertDeclareAtEnd(
1275+
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
12771276
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
12781277
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
12791278

@@ -1286,10 +1285,12 @@ LLVMDbgInstRef LLVMDIBuilderInsertDeclareAtEnd(
12861285
* \param DebugLoc Debug info location.
12871286
* \param Instr Instruction acting as a location for the new intrinsic.
12881287
*/
1289-
LLVMDbgInstRef
1290-
LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
1291-
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1292-
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1288+
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
1289+
LLVMValueRef Val,
1290+
LLVMMetadataRef VarInfo,
1291+
LLVMMetadataRef Expr,
1292+
LLVMMetadataRef DebugLoc,
1293+
LLVMValueRef Instr);
12931294

12941295
/**
12951296
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
@@ -1302,9 +1303,12 @@ LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
13021303
* \param DebugLoc Debug info location.
13031304
* \param Block Basic block acting as a location for the new intrinsic.
13041305
*/
1305-
LLVMDbgInstRef LLVMDIBuilderInsertDbgValueAtEnd(
1306-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1307-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1306+
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
1307+
LLVMValueRef Val,
1308+
LLVMMetadataRef VarInfo,
1309+
LLVMMetadataRef Expr,
1310+
LLVMMetadataRef DebugLoc,
1311+
LLVMBasicBlockRef Block);
13081312

13091313
/**
13101314
* Create a new descriptor for a local auto variable.

llvm/include/llvm-c/Types.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,6 @@ typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
173173
* @}
174174
*/
175175

176-
typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecord;
177-
typedef struct {
178-
union {
179-
LLVMValueRef Instr;
180-
LLVMDbgRecord Record;
181-
} Ptr;
182-
int IsInstr;
183-
} LLVMDbgInstRef;
184-
185176
LLVM_C_EXTERN_C_END
186177

187178
#endif

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ namespace llvm {
4242

4343
using DbgInstPtr = PointerUnion<Instruction *, DbgRecord *>;
4444

45-
/* Specialized opaque type conversions.
46-
*/
47-
inline DbgInstPtr unwrapDbgUnion(LLVMDbgInstRef Ref) {
48-
DbgInstPtr Unwrapped;
49-
if (Ref.IsInstr)
50-
Unwrapped = unwrap<Instruction>(Ref.Ptr.Instr);
51-
else
52-
Unwrapped = reinterpret_cast<DbgRecord *>(Ref.Ptr.Record);
53-
return Unwrapped;
54-
}
55-
inline LLVMDbgInstRef wrapDbgUnion(DbgInstPtr Ref) {
56-
LLVMDbgInstRef Wrapped;
57-
if (isa<Instruction *>(Ref)) {
58-
Wrapped.Ptr.Instr =
59-
wrap(reinterpret_cast<Value *>(Ref.get<Instruction *>()));
60-
Wrapped.IsInstr = true;
61-
} else {
62-
Wrapped.Ptr.Record =
63-
reinterpret_cast<LLVMDbgRecord>(Ref.get<DbgRecord *>());
64-
Wrapped.IsInstr = false;
65-
}
66-
return Wrapped;
67-
}
68-
6945
class DIBuilder {
7046
Module &M;
7147
LLVMContext &VMContext;

llvm/lib/IR/DebugInfo.cpp

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

1662-
LLVMDbgInstRef
1662+
LLVMValueRef
16631663
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
16641664
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
16651665
LLVMMetadataRef DL, LLVMValueRef Instr) {
1666-
return wrapDbgUnion(unwrap(Builder)->insertDeclare(
1667-
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1668-
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1669-
unwrap<Instruction>(Instr)));
1670-
}
1671-
1672-
LLVMDbgInstRef
1673-
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
1674-
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1675-
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
1676-
return wrapDbgUnion(unwrap(Builder)->insertDeclare(
1677-
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1678-
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block)));
1679-
}
1680-
1681-
LLVMDbgInstRef LLVMDIBuilderInsertDbgValueBefore(
1682-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1683-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
1684-
return wrapDbgUnion(unwrap(Builder)->insertDbgValueIntrinsic(
1685-
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1686-
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr)));
1687-
}
1688-
1689-
LLVMDbgInstRef LLVMDIBuilderInsertDbgValueAtEnd(
1690-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1691-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
1692-
return wrapDbgUnion(unwrap(Builder)->insertDbgValueIntrinsic(
1693-
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1694-
unwrap<DILocation>(DebugLoc), unwrap(Block)));
1666+
return LLVMValueRef();
1667+
// FIXME: What to do here?
1668+
/*
1669+
return wrap(unwrap(Builder)->insertDeclare(
1670+
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1671+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1672+
unwrap<Instruction>(Instr)));
1673+
*/
1674+
}
1675+
1676+
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
1677+
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1678+
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
1679+
return LLVMValueRef();
1680+
// FIXME: What to do here?
1681+
/*
1682+
return wrap(unwrap(Builder)->insertDeclare(
1683+
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1684+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1685+
unwrap(Block)));
1686+
*/
1687+
}
1688+
1689+
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
1690+
LLVMValueRef Val,
1691+
LLVMMetadataRef VarInfo,
1692+
LLVMMetadataRef Expr,
1693+
LLVMMetadataRef DebugLoc,
1694+
LLVMValueRef Instr) {
1695+
return LLVMValueRef();
1696+
// FIXME: What to do here?
1697+
/*
1698+
return wrap(unwrap(Builder)->insertDbgValueIntrinsic(
1699+
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1700+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1701+
unwrap<Instruction>(Instr)));
1702+
*/
1703+
}
1704+
1705+
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
1706+
LLVMValueRef Val,
1707+
LLVMMetadataRef VarInfo,
1708+
LLVMMetadataRef Expr,
1709+
LLVMMetadataRef DebugLoc,
1710+
LLVMBasicBlockRef Block) {
1711+
return LLVMValueRef();
1712+
// FIXME: What to do here?
1713+
/*
1714+
return wrap(unwrap(Builder)->insertDbgValueIntrinsic(
1715+
unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1716+
unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1717+
unwrap(Block)));
1718+
*/
16951719
}
16961720

16971721
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(

0 commit comments

Comments
 (0)