Skip to content

Commit 1459b28

Browse files
committed
Add pointer argument to OCaml debuginfo test function
1 parent 57fad57 commit 1459b28

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

llvm/include/llvm-c/DebugInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ enum {
173173
LLVMDISubrangeMetadataKind,
174174
LLVMDIEnumeratorMetadataKind,
175175
LLVMDIBasicTypeMetadataKind,
176-
LLVMDIFixedPointTypeMetadataKind,
177176
LLVMDIDerivedTypeMetadataKind,
178177
LLVMDICompositeTypeMetadataKind,
179178
LLVMDISubroutineTypeMetadataKind,
@@ -199,6 +198,7 @@ enum {
199198
LLVMDIArgListMetadataKind,
200199
LLVMDIAssignIDMetadataKind,
201200
LLVMDISubrangeTypeMetadataKind,
201+
LLVMDIFixedPointTypeMetadataKind,
202202
};
203203
typedef unsigned LLVMMetadataKind;
204204

llvm/test/Bindings/OCaml/debuginfo.ml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,18 @@ let test_get_function m dibuilder file_di m_di =
112112
stdout_metadata int_ty_di;
113113
(* CHECK: [[INT32_PTR:<0x[0-9a-f]*>]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
114114
*)
115-
let param_types = [| null_metadata; int_ty_di |] in
115+
let int_ptr_ty_di =
116+
Llvm_debuginfo.dibuild_create_pointer_type dibuilder
117+
~pointee_ty:int_ty_di
118+
~size_in_bits:32
119+
~align_in_bits:32
120+
~address_space:0
121+
~name:"ptrint"
122+
in
123+
stdout_metadata int_ptr_ty_di;
124+
(* CHECK: [[PTRINT32_PTR:<0x[0-9a-f]*>]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "ptrint", baseType: [[INT32_PTR]], size: 32, align: 32, dwarfAddressSpace: 0)
125+
*)
126+
let param_types = [| null_metadata; int_ty_di; int_ptr_ty_di |] in
116127
let fty_di =
117128
Llvm_debuginfo.dibuild_create_subroutine_type dibuilder ~file:file_di
118129
~param_types flags_zero
@@ -126,15 +137,16 @@ let test_get_function m dibuilder file_di m_di =
126137
Llvm_debuginfo.dibuild_get_or_create_type_array dibuilder ~data:param_types
127138
in
128139
stdout_metadata fty_di_args;
129-
(* CHECK: [[FARGS_PTR:<0x[0-9a-f]*>]] = !{null, [[INT32_PTR]]}
140+
(* CHECK: [[FARGS_PTR:<0x[0-9a-f]*>]] = !{null, [[INT32_PTR]], [[PTRINT32_PTR]]}
130141
*)
131142
stdout_metadata fty_di;
132143
(* CHECK: [[SBRTNTY_PTR:<0x[0-9a-f]*>]] = !DISubroutineType(types: [[FARGS_PTR]])
133144
*)
134145
(* Let's create the LLVM-IR function now. *)
135146
let name = "tfun" in
136147
let fty =
137-
Llvm.function_type (Llvm.void_type context) [| Llvm.i32_type context |]
148+
Llvm.function_type (Llvm.void_type context)
149+
[| Llvm.i32_type context; Llvm.pointer_type context |]
138150
in
139151
let f = Llvm.define_function name fty m in
140152
let f_di =
@@ -160,11 +172,12 @@ let test_bbinstr fty f f_di file_di dibuilder =
160172
group "basic_block and instructions tests";
161173
(* Create this pattern:
162174
* if (arg0 != 0) {
163-
* foo(arg0);
175+
* foo(arg0, arg1);
164176
* }
165177
* return;
166178
*)
167179
let arg0 = (Llvm.params f).(0) in
180+
let arg1 = (Llvm.params f).(1) in
168181
let builder = Llvm.builder_at_end context (Llvm.entry_block f) in
169182
let zero = Llvm.const_int (Llvm.i32_type context) 0 in
170183
let cmpi = Llvm.build_icmp Llvm.Icmp.Ne zero arg0 "cmpi" builder in
@@ -185,7 +198,7 @@ let test_bbinstr fty f f_di file_di dibuilder =
185198
| Some file_of_f_di', Some file_of_scope' ->
186199
file_of_f_di' = file_di && file_of_scope' = file_di
187200
| _ -> false );
188-
let foocall = Llvm.build_call fty foodecl [| arg0 |] "" builder in
201+
let foocall = Llvm.build_call fty foodecl [| arg0; arg1 |] "" builder in
189202
let foocall_loc =
190203
Llvm_debuginfo.dibuild_create_debug_location context ~line:10 ~column:12
191204
~scope
@@ -290,6 +303,18 @@ let test_variables f dibuilder file_di fun_di =
290303
let () = Printf.printf "%s\n" (Llvm.string_of_lldbgrecord vdi) in
291304
(* CHECK: dbg_declare(ptr %my_alloca, ![[#]], !DIExpression(), ![[#]])
292305
*)
306+
let arg1 = (Llvm.params f).(1) in
307+
let arg_var = Llvm_debuginfo.dibuild_create_parameter_variable dibuilder ~scope:fun_di
308+
~name:"my_arg" ~argno:1 ~file:file_di ~line:10 ~ty
309+
~always_preserve:false flags_zero
310+
in
311+
let argdi = Llvm_debuginfo.dibuild_insert_declare_before dibuilder ~storage:arg1
312+
~var_info:arg_var ~expr:(Llvm_debuginfo.dibuild_expression dibuilder [||])
313+
~location ~instr:entry_term
314+
in
315+
let () = Printf.printf "%s\n" (Llvm.string_of_lldbgrecord argdi) in
316+
(* CHECK: dbg_declare(ptr %1, ![[#]], !DIExpression(), ![[#]])
317+
*)
293318
()
294319

295320
let test_types dibuilder file_di m_di =

0 commit comments

Comments
 (0)