aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c15
-rw-r--r--llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml10
-rw-r--r--llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli10
-rw-r--r--llvm/bindings/ocaml/llvm/llvm.ml2
-rw-r--r--llvm/bindings/ocaml/llvm/llvm.mli6
-rw-r--r--llvm/bindings/ocaml/llvm/llvm_ocaml.c9
-rw-r--r--llvm/bindings/ocaml/llvm/llvm_ocaml.h1
-rw-r--r--llvm/docs/RemoveDIsDebugInfo.md11
-rw-r--r--llvm/include/llvm-c/Core.h8
-rw-r--r--llvm/include/llvm-c/DebugInfo.h60
-rw-r--r--llvm/lib/IR/Core.cpp14
-rw-r--r--llvm/lib/IR/DebugInfo.cpp121
-rw-r--r--llvm/test/Bindings/OCaml/debuginfo.ml10
-rw-r--r--llvm/tools/llvm-c-test/debuginfo.c13
14 files changed, 212 insertions, 78 deletions
diff --git a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
index a793e893..fbe45c0 100644
--- a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
+++ b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
@@ -972,7 +972,7 @@ value llvm_dibuild_create_parameter_variable_bytecode(value *argv, int arg) {
value llvm_dibuild_insert_declare_before_native(value Builder, value Storage,
value VarInfo, value Expr,
value DebugLoc, value Instr) {
- LLVMValueRef Value = LLVMDIBuilderInsertDeclareBefore(
+ LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareBefore(
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
Metadata_val(Expr), Metadata_val(DebugLoc), Value_val(Instr));
return to_val(Value);
@@ -992,7 +992,7 @@ value llvm_dibuild_insert_declare_before_bytecode(value *argv, int arg) {
value llvm_dibuild_insert_declare_at_end_native(value Builder, value Storage,
value VarInfo, value Expr,
value DebugLoc, value Block) {
- LLVMValueRef Value = LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareAtEnd(
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
Metadata_val(Expr), Metadata_val(DebugLoc), BasicBlock_val(Block));
return to_val(Value);
@@ -1012,3 +1012,14 @@ value llvm_dibuild_expression(value Builder, value Addr) {
return to_val(LLVMDIBuilderCreateExpression(
DIBuilder_val(Builder), (uint64_t *)Op_val(Addr), Wosize_val(Addr)));
}
+
+/* llmodule -> bool */
+value llvm_is_new_dbg_info_format(value Module) {
+ return Val_bool(LLVMIsNewDbgInfoFormat(Module_val(Module)));
+}
+
+/* llmodule -> bool -> unit */
+value llvm_set_is_new_dbg_info_format(value Module, value UseNewFormat) {
+ LLVMSetIsNewDbgInfoFormat(Module_val(Module), Bool_val(UseNewFormat));
+ return Val_unit;
+}
diff --git a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml
index a6d74ed..8bb5edb 100644
--- a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml
+++ b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml
@@ -599,7 +599,7 @@ external dibuild_insert_declare_before :
expr:Llvm.llmetadata ->
location:Llvm.llmetadata ->
instr:Llvm.llvalue ->
- Llvm.llvalue
+ Llvm.lldbgrecord
= "llvm_dibuild_insert_declare_before_bytecode" "llvm_dibuild_insert_declare_before_native"
external dibuild_insert_declare_at_end :
@@ -609,7 +609,7 @@ external dibuild_insert_declare_at_end :
expr:Llvm.llmetadata ->
location:Llvm.llmetadata ->
block:Llvm.llbasicblock ->
- Llvm.llvalue
+ Llvm.lldbgrecord
= "llvm_dibuild_insert_declare_at_end_bytecode" "llvm_dibuild_insert_declare_at_end_native"
external dibuild_expression :
@@ -617,3 +617,9 @@ external dibuild_expression :
Int64.t array ->
Llvm.llmetadata
= "llvm_dibuild_expression"
+
+external is_new_dbg_info_format : Llvm.llmodule -> bool
+ = "llvm_is_new_dbg_info_format"
+
+external set_is_new_dbg_info_format : Llvm.llmodule -> bool -> unit
+ = "llvm_set_is_new_dbg_info_format"
diff --git a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli
index e92778b..7c7882c 100644
--- a/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli
+++ b/llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli
@@ -659,7 +659,7 @@ val dibuild_insert_declare_before :
expr:Llvm.llmetadata ->
location:Llvm.llmetadata ->
instr:Llvm.llvalue ->
- Llvm.llvalue
+ Llvm.lldbgrecord
(** [dibuild_insert_declare_before] Insert a new llvm.dbg.declare
intrinsic call before the given instruction [instr]. *)
@@ -670,7 +670,7 @@ val dibuild_insert_declare_at_end :
expr:Llvm.llmetadata ->
location:Llvm.llmetadata ->
block:Llvm.llbasicblock ->
- Llvm.llvalue
+ Llvm.lldbgrecord
(** [dibuild_insert_declare_at_end] Insert a new llvm.dbg.declare
intrinsic call at the end of basic block [block]. If [block]
has a terminator instruction, the intrinsic is inserted
@@ -680,3 +680,9 @@ val dibuild_expression : lldibuilder -> Int64.t array -> Llvm.llmetadata
(** [dibuild_expression] Create a new descriptor for the specified variable
which has a complex address expression for its address.
See LLVMDIBuilderCreateExpression. *)
+
+val is_new_dbg_info_format : Llvm.llmodule -> bool
+(** [is_new_dbg_info_format] See LLVMIsNewDbgInfoFormat *)
+
+val set_is_new_dbg_info_format : Llvm.llmodule -> bool -> unit
+(** [set_is_new_dbg_info_format] See LLVMSetIsNewDbgInfoFormat *)
diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index 057798f..003fd75 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -12,6 +12,7 @@ type llmodule
type llmetadata
type lltype
type llvalue
+type lldbgrecord
type lluse
type llbasicblock
type llbuilder
@@ -528,6 +529,7 @@ external value_name : llvalue -> string = "llvm_value_name"
external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
external dump_value : llvalue -> unit = "llvm_dump_value"
external string_of_llvalue : llvalue -> string = "llvm_string_of_llvalue"
+external string_of_lldbgrecord : lldbgrecord -> string = "llvm_string_of_lldbgrecord"
external replace_all_uses_with : llvalue -> llvalue -> unit
= "llvm_replace_all_uses_with"
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index e0febb7..93540c6 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -36,6 +36,9 @@ type lltype
This type covers a wide range of subclasses. *)
type llvalue
+(** Non-instruction debug info record. See the [llvm::DbgRecord] class.*)
+type lldbgrecord
+
(** Used to store users and usees of values. See the [llvm::Use] class. *)
type lluse
@@ -793,6 +796,9 @@ val dump_value : llvalue -> unit
(** [string_of_llvalue v] returns a string describing the value [v]. *)
val string_of_llvalue : llvalue -> string
+(** [string_of_lldbgrecord r] returns a string describing the DbgRecord [r]. *)
+val string_of_lldbgrecord : lldbgrecord -> string
+
(** [replace_all_uses_with old new] replaces all uses of the value [old]
with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
val replace_all_uses_with : llvalue -> llvalue -> unit
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index 55679f2..6d08d78 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -800,6 +800,15 @@ value llvm_string_of_llvalue(value M) {
return ValueStr;
}
+/* lldbgrecord -> string */
+value llvm_string_of_lldbgrecord(value Record) {
+ char *ValueCStr = LLVMPrintDbgRecordToString(DbgRecord_val(Record));
+ value ValueStr = caml_copy_string(ValueCStr);
+ LLVMDisposeMessage(ValueCStr);
+
+ return ValueStr;
+}
+
/* llvalue -> llvalue -> unit */
value llvm_replace_all_uses_with(value OldVal, value NewVal) {
LLVMReplaceAllUsesWith(Value_val(OldVal), Value_val(NewVal));
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.h b/llvm/bindings/ocaml/llvm/llvm_ocaml.h
index a379174..ec60d6a 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.h
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.h
@@ -53,6 +53,7 @@ void *from_val_array(value Elements);
#define Metadata_val(v) ((LLVMMetadataRef)from_val(v))
#define Type_val(v) ((LLVMTypeRef)from_val(v))
#define Value_val(v) ((LLVMValueRef)from_val(v))
+#define DbgRecord_val(v) ((LLVMDbgRecordRef)from_val(v))
#define Use_val(v) ((LLVMUseRef)from_val(v))
#define BasicBlock_val(v) ((LLVMBasicBlockRef)from_val(v))
#define MemoryBuffer_val(v) ((LLVMMemoryBufferRef)from_val(v))
diff --git a/llvm/docs/RemoveDIsDebugInfo.md b/llvm/docs/RemoveDIsDebugInfo.md
index a2f1e17..9e50a2a 100644
--- a/llvm/docs/RemoveDIsDebugInfo.md
+++ b/llvm/docs/RemoveDIsDebugInfo.md
@@ -40,15 +40,22 @@ New functions (all to be deprecated)
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
-LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
+LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
-LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
+LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above.
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above.
+
+Existing functions (behaviour change)
+-------------------------------------
+LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
+LLVMDIBuilderInsertDeclareAtEnd # Same as above.
+LLVMDIBuilderInsertDbgValueBefore # Same as above.
+LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
```
# Anything else?
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 254c298..6be5957 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -1867,6 +1867,14 @@ void LLVMDumpValue(LLVMValueRef Val);
char *LLVMPrintValueToString(LLVMValueRef Val);
/**
+ * Return a string representation of the DbgRecord. Use
+ * LLVMDisposeMessage to free the string.
+ *
+ * @see llvm::DbgRecord::print()
+ */
+char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);
+
+/**
* Replace all uses of a value with another one.
*
* @see llvm::Value::replaceAllUsesWith()
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index b23ff63..dab1d69 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -1249,7 +1249,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
LLVMMetadataRef Decl, uint32_t AlignInBits);
/*
- * Insert a new llvm.dbg.declare intrinsic call before the given instruction.
+ * Insert a new Declare DbgRecord before the given instruction.
+ *
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
+ * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
* \param Builder The DIBuilder.
* \param Storage The storage of the variable to declare.
* \param VarInfo The variable's debug info descriptor.
@@ -1257,13 +1262,13 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
-LLVMValueRef
+LLVMDbgRecordRef
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).
+ * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
@@ -1279,7 +1284,7 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
- * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a Declare DbgRecord before the given instruction.
@@ -1295,9 +1300,14 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
- * 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.
+ * Insert a new Declare DbgRecord at the end of the given basic block. If the
+ * basic block has a terminator instruction, the intrinsic is inserted before
+ * that terminator instruction.
+ *
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
+ * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
* \param Builder The DIBuilder.
* \param Storage The storage of the variable to declare.
* \param VarInfo The variable's debug info descriptor.
@@ -1305,12 +1315,12 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
* \param DebugLoc Debug info location.
* \param Block Basic block acting as a location for the new intrinsic.
*/
-LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
- * Only use in "old debug mode" (LLVMIsNewDbgFormat() is false).
+ * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
@@ -1328,7 +1338,7 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
- * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a Declare DbgRecord at the end of the given basic block. If the basic
@@ -1346,7 +1356,12 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
- * Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ * Insert a new Value DbgRecord before the given instruction.
+ *
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
+ * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
* \param Builder The DIBuilder.
* \param Val The value of the variable.
* \param VarInfo The variable's debug info descriptor.
@@ -1354,13 +1369,13 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
-LLVMValueRef
+LLVMDbgRecordRef
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).
+ * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
@@ -1376,7 +1391,7 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Soon to be deprecated.
- * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
@@ -1392,9 +1407,14 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
- * 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.
+ * Insert a new Value DbgRecord at the end of the given basic block. If the
+ * basic block has a terminator instruction, the intrinsic is inserted before
+ * that terminator instruction.
+ *
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
+ * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
* \param Builder The DIBuilder.
* \param Val The value of the variable.
* \param VarInfo The variable's debug info descriptor.
@@ -1402,12 +1422,12 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
* \param DebugLoc Debug info location.
* \param Block Basic block acting as a location for the new intrinsic.
*/
-LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
- * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
+ * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
@@ -1425,7 +1445,7 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Soon to be deprecated.
- * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
+ * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 3aee619..8ce9c5c 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -990,6 +990,20 @@ char* LLVMPrintValueToString(LLVMValueRef Val) {
return strdup(buf.c_str());
}
+char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record) {
+ std::string buf;
+ raw_string_ostream os(buf);
+
+ if (unwrap(Record))
+ unwrap(Record)->print(os);
+ else
+ os << "Printing <null> DbgRecord";
+
+ os.flush();
+
+ return strdup(buf.c_str());
+}
+
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
}
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 09bce9d..4206162 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1665,12 +1665,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
}
-LLVMValueRef
+LLVMDbgRecordRef
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMValueRef Instr) {
- return LLVMDIBuilderInsertDeclareIntrinsicBefore(Builder, Storage, VarInfo,
- Expr, DL, Instr);
+ return LLVMDIBuilderInsertDeclareRecordBefore(Builder, Storage, VarInfo, Expr,
+ DL, Instr);
}
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
@@ -1679,27 +1679,38 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
unwrap<Instruction>(Instr));
+ // This assert will fail if the module is in the new debug info format.
+ // This function should only be called if the module is in the old
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
- "Inserted a DbgRecord into function using old debug info mode");
+ "Function unexpectedly in new debug info format");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
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 *>());
+ DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
+ unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
+ unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
+ unwrap<Instruction>(Instr));
+ // This assert will fail if the module is in the old debug info format.
+ // This function should only be called if the module is in the new
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMValueRef
+LLVMDbgRecordRef
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
- return LLVMDIBuilderInsertDeclareIntrinsicAtEnd(Builder, Storage, VarInfo,
- Expr, DL, Block);
+ return LLVMDIBuilderInsertDeclareRecordAtEnd(Builder, Storage, VarInfo, Expr,
+ DL, Block);
}
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
@@ -1707,26 +1718,36 @@ LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
+ // This assert will fail if the module is in the new debug info format.
+ // This function should only be called if the module is in the old
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
- "Inserted a DbgRecord into function using old debug info mode");
+ "Function unexpectedly in new debug info format");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
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));
+ // This assert will fail if the module is in the old debug info format.
+ // This function should only be called if the module is in the new
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
- return LLVMDIBuilderInsertDbgValueIntrinsicBefore(Builder, Val, VarInfo, Expr,
- DebugLoc, Instr);
+ return LLVMDIBuilderInsertDbgValueRecordBefore(Builder, Val, VarInfo, Expr,
+ DebugLoc, Instr);
}
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
@@ -1734,26 +1755,36 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
+ // This assert will fail if the module is in the new debug info format.
+ // This function should only be called if the module is in the old
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
- "Inserted a DbgRecord into function using old debug info mode");
+ "Function unexpectedly in new debug info format");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
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));
+ // This assert will fail if the module is in the old debug info format.
+ // This function should only be called if the module is in the new
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
- return LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(Builder, Val, VarInfo, Expr,
- DebugLoc, Block);
+ return LLVMDIBuilderInsertDbgValueRecordAtEnd(Builder, Val, VarInfo, Expr,
+ DebugLoc, Block);
}
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
@@ -1761,19 +1792,29 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
unwrap<DILocation>(DebugLoc), unwrap(Block));
+ // This assert will fail if the module is in the new debug info format.
+ // This function should only be called if the module is in the old
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
assert(isa<Instruction *>(DbgInst) &&
- "Inserted a DbgRecord into function using old debug info mode");
+ "Function unexpectedly in new debug info format");
return wrap(cast<Instruction *>(DbgInst));
}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
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));
+ // This assert will fail if the module is in the old debug info format.
+ // This function should only be called if the module is in the new
+ // debug info format.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
}
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(
diff --git a/llvm/test/Bindings/OCaml/debuginfo.ml b/llvm/test/Bindings/OCaml/debuginfo.ml
index d469d47..f95800d 100644
--- a/llvm/test/Bindings/OCaml/debuginfo.ml
+++ b/llvm/test/Bindings/OCaml/debuginfo.ml
@@ -39,6 +39,8 @@ let prepare_target llmod =
let new_module () =
let m = Llvm.create_module context module_name in
let () = prepare_target m in
+ let () = Llvm_debuginfo.set_is_new_dbg_info_format m true in
+ insist (Llvm_debuginfo.is_new_dbg_info_format m);
m
let test_get_module () =
@@ -285,8 +287,8 @@ let test_variables f dibuilder file_di fun_di =
~var_info:auto_var ~expr:(Llvm_debuginfo.dibuild_expression dibuilder [||])
~location ~instr:entry_term
in
- let () = Printf.printf "%s\n" (Llvm.string_of_llvalue vdi) in
- (* CHECK: call void @llvm.dbg.declare(metadata ptr %my_alloca, metadata {{![0-9]+}}, metadata !DIExpression()), !dbg {{\![0-9]+}}
+ let () = Printf.printf "%s\n" (Llvm.string_of_lldbgrecord vdi) in
+ (* CHECK: dbg_declare(ptr %my_alloca, ![[#]], !DIExpression(), ![[#]])
*)
let arg0 = (Llvm.params f).(0) in
let arg_var = Llvm_debuginfo.dibuild_create_parameter_variable dibuilder ~scope:fun_di
@@ -297,8 +299,8 @@ let test_variables f dibuilder file_di fun_di =
~var_info:arg_var ~expr:(Llvm_debuginfo.dibuild_expression dibuilder [||])
~location ~instr:entry_term
in
- let () = Printf.printf "%s\n" (Llvm.string_of_llvalue argdi) in
- (* CHECK: call void @llvm.dbg.declare(metadata i32 %0, metadata {{![0-9]+}}, metadata !DIExpression()), !dbg {{\![0-9]+}}
+ let () = Printf.printf "%s\n" (Llvm.string_of_lldbgrecord argdi) in
+ (* CHECK: dbg_declare(i32 %0, ![[#]], !DIExpression(), ![[#]])
*)
()
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
index 78ccaf1..9b5c37b 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -136,12 +136,13 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
LLVMMetadataRef FooParamVar1 =
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File,
42, Int64Ty, true, 0);
+
if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareRecordAtEnd(
+ LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
- LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
FooParamExpression, FooParamLocation, FooEntryBlock);
LLVMMetadataRef FooParamVar2 =
@@ -149,11 +150,11 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
42, Int64Ty, true, 0);
if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareRecordAtEnd(
+ LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
- LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
FooParamExpression, FooParamLocation, FooEntryBlock);
@@ -161,11 +162,11 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File,
42, VectorTy, true, 0);
if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareRecordAtEnd(
+ LLVMDIBuilderInsertDeclareAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
FooParamExpression, FooParamLocation, FooEntryBlock);
else
- LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
FooParamExpression, FooParamLocation, FooEntryBlock);