[NFC][Py Reformat] Reformat python files in llvm
[llvm-project.git] / llvm / test / Bindings / OCaml / debuginfo.ml
blobd35b2b72f229686387e13bb40d13db2fff410bfa
1 (* RUN: rm -rf %t && mkdir -p %t && cp %s %t/debuginfo.ml && cp %S/Utils/Testsuite.ml %t/Testsuite.ml
2 * RUN: %ocamlc -g -w +A -package llvm.all_backends -package llvm.target -package llvm.analysis -package llvm.debuginfo -I %t/ -linkpkg %t/Testsuite.ml %t/debuginfo.ml -o %t/executable
3 * RUN: %t/executable | FileCheck %s
4 * RUN: %ocamlopt -g -w +A -package llvm.all_backends -package llvm.target -package llvm.analysis -package llvm.debuginfo -I %t/ -linkpkg %t/Testsuite.ml %t/debuginfo.ml -o %t/executable
5 * RUN: %t/executable | FileCheck %s
6 * XFAIL: vg_leak
7 *)
9 open Testsuite
11 let context = Llvm.global_context ()
13 let filename = "di_test_file"
15 let directory = "di_test_dir"
17 let module_name = "di_test_module"
19 let null_metadata = Llvm_debuginfo.llmetadata_null ()
21 let string_of_metadata md =
22 Llvm.string_of_llvalue (Llvm.metadata_as_value context md)
24 let stdout_metadata md = Printf.printf "%s\n" (string_of_metadata md)
26 let prepare_target llmod =
27 Llvm_all_backends.initialize ();
28 let triple = Llvm_target.Target.default_triple () in
29 let lltarget = Llvm_target.Target.by_triple triple in
30 let llmachine = Llvm_target.TargetMachine.create ~triple lltarget in
31 let lldly =
32 Llvm_target.DataLayout.as_string
33 (Llvm_target.TargetMachine.data_layout llmachine)
35 let _ = Llvm.set_target_triple triple llmod in
36 let _ = Llvm.set_data_layout lldly llmod in
39 let new_module () =
40 let m = Llvm.create_module context module_name in
41 let () = prepare_target m in
44 let test_get_module () =
45 group "module_level_tests";
46 let m = new_module () in
47 let cur_ver = Llvm_debuginfo.debug_metadata_version () in
48 insist (cur_ver > 0);
49 let m_ver = Llvm_debuginfo.get_module_debug_metadata_version m in
50 (* We haven't added any debug info to the module *)
51 insist (m_ver = 0);
52 let dibuilder = Llvm_debuginfo.dibuilder m in
53 let di_version_key = "Debug Info Version" in
54 let ver =
55 Llvm.value_as_metadata @@ Llvm.const_int (Llvm.i32_type context) cur_ver
57 let () =
58 Llvm.add_module_flag m Llvm.ModuleFlagBehavior.Warning di_version_key ver
60 let file_di =
61 Llvm_debuginfo.dibuild_create_file dibuilder ~filename ~directory
63 stdout_metadata file_di;
64 (* CHECK: [[FILE_PTR:<0x[0-9a-f]*>]] = !DIFile(filename: "di_test_file", directory: "di_test_dir")
66 insist
67 ( Llvm_debuginfo.di_file_get_filename ~file:file_di = filename
68 && Llvm_debuginfo.di_file_get_directory ~file:file_di = directory );
69 insist
70 ( Llvm_debuginfo.get_metadata_kind file_di
71 = Llvm_debuginfo.MetadataKind.DIFileMetadataKind );
72 let cu_di =
73 Llvm_debuginfo.dibuild_create_compile_unit dibuilder
74 Llvm_debuginfo.DWARFSourceLanguageKind.C89 ~file_ref:file_di
75 ~producer:"TestGen" ~is_optimized:false ~flags:"" ~runtime_ver:0
76 ~split_name:"" Llvm_debuginfo.DWARFEmissionKind.LineTablesOnly ~dwoid:0
77 ~di_inlining:false ~di_profiling:false ~sys_root:"" ~sdk:""
79 stdout_metadata cu_di;
80 (* CHECK: [[CMPUNIT_PTR:<0x[0-9a-f]*>]] = distinct !DICompileUnit(language: DW_LANG_C89, file: [[FILE_PTR]], producer: "TestGen", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false)
82 insist
83 ( Llvm_debuginfo.get_metadata_kind cu_di
84 = Llvm_debuginfo.MetadataKind.DICompileUnitMetadataKind );
85 let m_di =
86 Llvm_debuginfo.dibuild_create_module dibuilder ~parent_ref:cu_di
87 ~name:module_name ~config_macros:"" ~include_path:"" ~sys_root:""
89 insist
90 ( Llvm_debuginfo.get_metadata_kind m_di
91 = Llvm_debuginfo.MetadataKind.DIModuleMetadataKind );
92 insist (Llvm_debuginfo.get_module_debug_metadata_version m = cur_ver);
93 stdout_metadata m_di;
94 (* CHECK: [[MODULE_PTR:<0x[0-9a-f]*>]] = !DIModule(scope: null, name: "di_test_module")
96 (m, dibuilder, file_di, m_di)
98 let flags_zero = Llvm_debuginfo.diflags_get Llvm_debuginfo.DIFlag.Zero
100 let int_ty_di bits dibuilder =
101 Llvm_debuginfo.dibuild_create_basic_type dibuilder ~name:"int"
102 ~size_in_bits:bits ~encoding:0x05
103 (* llvm::dwarf::DW_ATE_signed *) flags_zero
105 let test_get_function m dibuilder file_di m_di =
106 group "function_level_tests";
108 (* Create a function of type "void foo (int)". *)
109 let int_ty_di = int_ty_di 32 dibuilder in
110 stdout_metadata int_ty_di;
111 (* CHECK: [[INT32_PTR:<0x[0-9a-f]*>]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
113 let param_types = [| null_metadata; int_ty_di |] in
114 let fty_di =
115 Llvm_debuginfo.dibuild_create_subroutine_type dibuilder ~file:file_di
116 ~param_types flags_zero
118 insist
119 ( Llvm_debuginfo.get_metadata_kind fty_di
120 = Llvm_debuginfo.MetadataKind.DISubroutineTypeMetadataKind );
121 (* To be able to print and verify the type array of the subroutine type,
122 * since we have no way to access it from fty_di, we build it again. *)
123 let fty_di_args =
124 Llvm_debuginfo.dibuild_get_or_create_type_array dibuilder ~data:param_types
126 stdout_metadata fty_di_args;
127 (* CHECK: [[FARGS_PTR:<0x[0-9a-f]*>]] = !{null, [[INT32_PTR]]}
129 stdout_metadata fty_di;
130 (* CHECK: [[SBRTNTY_PTR:<0x[0-9a-f]*>]] = !DISubroutineType(types: [[FARGS_PTR]])
132 (* Let's create the LLVM-IR function now. *)
133 let name = "tfun" in
134 let fty =
135 Llvm.function_type (Llvm.void_type context) [| Llvm.i32_type context |]
137 let f = Llvm.define_function name fty m in
138 let f_di =
139 Llvm_debuginfo.dibuild_create_function dibuilder ~scope:m_di ~name
140 ~linkage_name:name ~file:file_di ~line_no:10 ~ty:fty_di
141 ~is_local_to_unit:false ~is_definition:true ~scope_line:10
142 ~flags:flags_zero ~is_optimized:false
144 stdout_metadata f_di;
145 (* CHECK: [[SBPRG_PTR:<0x[0-9a-f]*>]] = distinct !DISubprogram(name: "tfun", linkageName: "tfun", scope: [[MODULE_PTR]], file: [[FILE_PTR]], line: 10, type: [[SBRTNTY_PTR]], scopeLine: 10, spFlags: DISPFlagDefinition, unit: [[CMPUNIT_PTR]], retainedNodes: {{<0x[0-9a-f]*>}})
147 Llvm_debuginfo.set_subprogram f f_di;
148 ( match Llvm_debuginfo.get_subprogram f with
149 | Some f_di' -> insist (f_di = f_di')
150 | None -> insist false );
151 insist
152 ( Llvm_debuginfo.get_metadata_kind f_di
153 = Llvm_debuginfo.MetadataKind.DISubprogramMetadataKind );
154 insist (Llvm_debuginfo.di_subprogram_get_line f_di = 10);
155 (fty, f, f_di)
157 let test_bbinstr fty f f_di file_di dibuilder =
158 group "basic_block and instructions tests";
159 (* Create this pattern:
160 * if (arg0 != 0) {
161 * foo(arg0);
163 * return;
165 let arg0 = (Llvm.params f).(0) in
166 let builder = Llvm.builder_at_end context (Llvm.entry_block f) in
167 let zero = Llvm.const_int (Llvm.i32_type context) 0 in
168 let cmpi = Llvm.build_icmp Llvm.Icmp.Ne zero arg0 "cmpi" builder in
169 let truebb = Llvm.append_block context "truebb" f in
170 let falsebb = Llvm.append_block context "falsebb" f in
171 let _ = Llvm.build_cond_br cmpi truebb falsebb builder in
172 let foodecl = Llvm.declare_function "foo" fty (Llvm.global_parent f) in
173 let _ =
174 Llvm.position_at_end truebb builder;
175 let scope =
176 Llvm_debuginfo.dibuild_create_lexical_block dibuilder ~scope:f_di
177 ~file:file_di ~line:9 ~column:4
179 let file_of_f_di = Llvm_debuginfo.di_scope_get_file ~scope:f_di in
180 let file_of_scope = Llvm_debuginfo.di_scope_get_file ~scope in
181 insist
182 ( match (file_of_f_di, file_of_scope) with
183 | Some file_of_f_di', Some file_of_scope' ->
184 file_of_f_di' = file_di && file_of_scope' = file_di
185 | _ -> false );
186 let foocall = Llvm.build_call fty foodecl [| arg0 |] "" builder in
187 let foocall_loc =
188 Llvm_debuginfo.dibuild_create_debug_location context ~line:10 ~column:12
189 ~scope
191 Llvm_debuginfo.instr_set_debug_loc foocall (Some foocall_loc);
192 insist
193 ( match Llvm_debuginfo.instr_get_debug_loc foocall with
194 | Some foocall_loc' -> foocall_loc' = foocall_loc
195 | None -> false );
196 stdout_metadata scope;
197 (* CHECK: [[BLOCK_PTR:<0x[0-9a-f]*>]] = distinct !DILexicalBlock(scope: [[SBPRG_PTR]], file: [[FILE_PTR]], line: 9, column: 4)
199 stdout_metadata foocall_loc;
200 (* CHECK: !DILocation(line: 10, column: 12, scope: [[BLOCK_PTR]])
202 insist
203 ( Llvm_debuginfo.di_location_get_scope ~location:foocall_loc = scope
204 && Llvm_debuginfo.di_location_get_line ~location:foocall_loc = 10
205 && Llvm_debuginfo.di_location_get_column ~location:foocall_loc = 12 );
206 insist
207 ( Llvm_debuginfo.get_metadata_kind foocall_loc
208 = Llvm_debuginfo.MetadataKind.DILocationMetadataKind
209 && Llvm_debuginfo.get_metadata_kind scope
210 = Llvm_debuginfo.MetadataKind.DILexicalBlockMetadataKind );
211 Llvm.build_br falsebb builder
213 let _ =
214 Llvm.position_at_end falsebb builder;
215 Llvm.build_ret_void builder
217 (* Printf.printf "%s\n" (Llvm.string_of_llmodule (Llvm.global_parent f)); *)
220 let test_global_variable_expression dibuilder f_di m_di =
221 group "global variable expression tests";
222 let cexpr_di =
223 Llvm_debuginfo.dibuild_create_constant_value_expression dibuilder 0
225 stdout_metadata cexpr_di;
226 (* CHECK: [[DICEXPR:!DIExpression\(DW_OP_constu, 0, DW_OP_stack_value\)]]
228 insist
229 ( Llvm_debuginfo.get_metadata_kind cexpr_di
230 = Llvm_debuginfo.MetadataKind.DIExpressionMetadataKind );
231 let ty = int_ty_di 64 dibuilder in
232 stdout_metadata ty;
233 (* CHECK: [[INT64TY_PTR:<0x[0-9a-f]*>]] = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_signed)
235 let gvexpr_di =
236 Llvm_debuginfo.dibuild_create_global_variable_expression dibuilder
237 ~scope:m_di ~name:"my_global" ~linkage:"" ~file:f_di ~line:5 ~ty
238 ~is_local_to_unit:true ~expr:cexpr_di ~decl:null_metadata ~align_in_bits:0
240 insist
241 ( Llvm_debuginfo.get_metadata_kind gvexpr_di
242 = Llvm_debuginfo.MetadataKind.DIGlobalVariableExpressionMetadataKind );
243 ( match
244 Llvm_debuginfo.di_global_variable_expression_get_variable gvexpr_di
245 with
246 | Some gvexpr_var_di ->
247 insist
248 ( Llvm_debuginfo.get_metadata_kind gvexpr_var_di
249 = Llvm_debuginfo.MetadataKind.DIGlobalVariableMetadataKind );
250 stdout_metadata gvexpr_var_di
251 (* CHECK: [[GV_PTR:<0x[0-9a-f]*>]] = distinct !DIGlobalVariable(name: "my_global", scope: [[MODULE_PTR]], file: [[FILE_PTR]], line: 5, type: [[INT64TY_PTR]], isLocal: true, isDefinition: true)
253 | None -> insist false );
254 stdout_metadata gvexpr_di;
255 (* CHECK: [[GVEXP_PTR:<0x[0-9a-f]*>]] = !DIGlobalVariableExpression(var: [[GV_PTR]], expr: [[DICEXPR]])
259 let test_variables f dibuilder file_di fun_di =
260 let entry_term = Option.get @@ (Llvm.block_terminator (Llvm.entry_block f)) in
261 group "Local and parameter variable tests";
262 let ty = int_ty_di 64 dibuilder in
263 stdout_metadata ty;
264 (* CHECK: [[INT64TY_PTR:<0x[0-9a-f]*>]] = !DIBasicType(name: "int", size: 64, encoding: DW_ATE_signed)
266 let auto_var =
267 Llvm_debuginfo.dibuild_create_auto_variable dibuilder ~scope:fun_di
268 ~name:"my_local" ~file:file_di ~line:10 ~ty
269 ~always_preserve:false flags_zero ~align_in_bits:0
271 stdout_metadata auto_var;
272 (* CHECK: [[LOCAL_VAR_PTR:<0x[0-9a-f]*>]] = !DILocalVariable(name: "my_local", scope: <{{0x[0-9a-f]*}}>, file: <{{0x[0-9a-f]*}}>, line: 10, type: [[INT64TY_PTR]])
274 let builder = Llvm.builder_before context entry_term in
275 let all = Llvm.build_alloca (Llvm.i64_type context) "my_alloca" builder in
276 let scope =
277 Llvm_debuginfo.dibuild_create_lexical_block dibuilder ~scope:fun_di
278 ~file:file_di ~line:9 ~column:4
280 let location =
281 Llvm_debuginfo.dibuild_create_debug_location
282 context ~line:10 ~column:12 ~scope
284 let vdi = Llvm_debuginfo.dibuild_insert_declare_before dibuilder ~storage:all
285 ~var_info:auto_var ~expr:(Llvm_debuginfo.dibuild_expression dibuilder [||])
286 ~location ~instr:entry_term
288 let () = Printf.printf "%s\n" (Llvm.string_of_llvalue vdi) in
289 (* CHECK: call void @llvm.dbg.declare(metadata ptr %my_alloca, metadata {{![0-9]+}}, metadata !DIExpression()), !dbg {{\![0-9]+}}
291 let arg0 = (Llvm.params f).(0) in
292 let arg_var = Llvm_debuginfo.dibuild_create_parameter_variable dibuilder ~scope:fun_di
293 ~name:"my_arg" ~argno:1 ~file:file_di ~line:10 ~ty
294 ~always_preserve:false flags_zero
296 let argdi = Llvm_debuginfo.dibuild_insert_declare_before dibuilder ~storage:arg0
297 ~var_info:arg_var ~expr:(Llvm_debuginfo.dibuild_expression dibuilder [||])
298 ~location ~instr:entry_term
300 let () = Printf.printf "%s\n" (Llvm.string_of_llvalue argdi) in
301 (* CHECK: call void @llvm.dbg.declare(metadata i32 %0, metadata {{![0-9]+}}, metadata !DIExpression()), !dbg {{\![0-9]+}}
305 let test_types dibuilder file_di m_di =
306 group "type tests";
307 let namespace_di =
308 Llvm_debuginfo.dibuild_create_namespace dibuilder ~parent_ref:m_di
309 ~name:"NameSpace1" ~export_symbols:false
311 stdout_metadata namespace_di;
312 (* CHECK: [[NAMESPACE_PTR:<0x[0-9a-f]*>]] = !DINamespace(name: "NameSpace1", scope: [[MODULE_PTR]])
314 let int64_ty_di = int_ty_di 64 dibuilder in
315 let structty_args = [| int64_ty_di; int64_ty_di; int64_ty_di |] in
316 let struct_ty_di =
317 Llvm_debuginfo.dibuild_create_struct_type dibuilder ~scope:namespace_di
318 ~name:"StructType1" ~file:file_di ~line_number:20 ~size_in_bits:192
319 ~align_in_bits:0 flags_zero ~derived_from:null_metadata
320 ~elements:structty_args Llvm_debuginfo.DWARFSourceLanguageKind.C89
321 ~vtable_holder:null_metadata ~unique_id:"StructType1"
323 (* Since there's no way to fetch the element types which is now
324 * a type array, we build that again for checking. *)
325 let structty_di_eltypes =
326 Llvm_debuginfo.dibuild_get_or_create_type_array dibuilder
327 ~data:structty_args
329 stdout_metadata structty_di_eltypes;
330 (* CHECK: [[STRUCTELT_PTR:<0x[0-9a-f]*>]] = !{[[INT64TY_PTR]], [[INT64TY_PTR]], [[INT64TY_PTR]]}
332 stdout_metadata struct_ty_di;
333 (* CHECK: [[STRUCT_PTR:<0x[0-9a-f]*>]] = !DICompositeType(tag: DW_TAG_structure_type, name: "StructType1", scope: [[NAMESPACE_PTR]], file: [[FILE_PTR]], line: 20, size: 192, elements: [[STRUCTELT_PTR]], identifier: "StructType1")
335 insist
336 ( Llvm_debuginfo.get_metadata_kind struct_ty_di
337 = Llvm_debuginfo.MetadataKind.DICompositeTypeMetadataKind );
338 let structptr_di =
339 Llvm_debuginfo.dibuild_create_pointer_type dibuilder
340 ~pointee_ty:struct_ty_di ~size_in_bits:192 ~align_in_bits:0
341 ~address_space:0 ~name:""
343 stdout_metadata structptr_di;
344 (* CHECK: [[STRUCTPTR_PTR:<0x[0-9a-f]*>]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[STRUCT_PTR]], size: 192, dwarfAddressSpace: 0)
346 insist
347 ( Llvm_debuginfo.get_metadata_kind structptr_di
348 = Llvm_debuginfo.MetadataKind.DIDerivedTypeMetadataKind );
349 let enumerator1 =
350 Llvm_debuginfo.dibuild_create_enumerator dibuilder ~name:"Test_A" ~value:0
351 ~is_unsigned:true
353 stdout_metadata enumerator1;
354 (* CHECK: [[ENUMERATOR1_PTR:<0x[0-9a-f]*>]] = !DIEnumerator(name: "Test_A", value: 0, isUnsigned: true)
356 let enumerator2 =
357 Llvm_debuginfo.dibuild_create_enumerator dibuilder ~name:"Test_B" ~value:1
358 ~is_unsigned:true
360 stdout_metadata enumerator2;
361 (* CHECK: [[ENUMERATOR2_PTR:<0x[0-9a-f]*>]] = !DIEnumerator(name: "Test_B", value: 1, isUnsigned: true)
363 let enumerator3 =
364 Llvm_debuginfo.dibuild_create_enumerator dibuilder ~name:"Test_C" ~value:2
365 ~is_unsigned:true
367 insist
368 ( Llvm_debuginfo.get_metadata_kind enumerator1
369 = Llvm_debuginfo.MetadataKind.DIEnumeratorMetadataKind
370 && Llvm_debuginfo.get_metadata_kind enumerator2
371 = Llvm_debuginfo.MetadataKind.DIEnumeratorMetadataKind
372 && Llvm_debuginfo.get_metadata_kind enumerator3
373 = Llvm_debuginfo.MetadataKind.DIEnumeratorMetadataKind );
374 stdout_metadata enumerator3;
375 (* CHECK: [[ENUMERATOR3_PTR:<0x[0-9a-f]*>]] = !DIEnumerator(name: "Test_C", value: 2, isUnsigned: true)
377 let elements = [| enumerator1; enumerator2; enumerator3 |] in
378 let enumeration_ty_di =
379 Llvm_debuginfo.dibuild_create_enumeration_type dibuilder ~scope:namespace_di
380 ~name:"EnumTest" ~file:file_di ~line_number:1 ~size_in_bits:64
381 ~align_in_bits:0 ~elements ~class_ty:int64_ty_di
383 let elements_arr =
384 Llvm_debuginfo.dibuild_get_or_create_array dibuilder ~data:elements
386 stdout_metadata elements_arr;
387 (* CHECK: [[ELEMENTS_PTR:<0x[0-9a-f]*>]] = !{[[ENUMERATOR1_PTR]], [[ENUMERATOR2_PTR]], [[ENUMERATOR3_PTR]]}
389 stdout_metadata enumeration_ty_di;
390 (* CHECK: [[ENUMERATION_PTR:<0x[0-9a-f]*>]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumTest", scope: [[NAMESPACE_PTR]], file: [[FILE_PTR]], line: 1, baseType: [[INT64TY_PTR]], size: 64, elements: [[ELEMENTS_PTR]])
392 insist
393 ( Llvm_debuginfo.get_metadata_kind enumeration_ty_di
394 = Llvm_debuginfo.MetadataKind.DICompositeTypeMetadataKind );
395 let int32_ty_di = int_ty_di 32 dibuilder in
396 let class_mem1 =
397 Llvm_debuginfo.dibuild_create_member_type dibuilder ~scope:namespace_di
398 ~name:"Field1" ~file:file_di ~line_number:3 ~size_in_bits:32
399 ~align_in_bits:0 ~offset_in_bits:0 flags_zero ~ty:int32_ty_di
401 stdout_metadata class_mem1;
402 (* CHECK: [[MEMB1_PTR:<0x[0-9a-f]*>]] = !DIDerivedType(tag: DW_TAG_member, name: "Field1", scope: [[NAMESPACE_PTR]], file: [[FILE_PTR]], line: 3, baseType: [[INT32_PTR]], size: 32)
404 insist (Llvm_debuginfo.di_type_get_name class_mem1 = "Field1");
405 insist (Llvm_debuginfo.di_type_get_line class_mem1 = 3);
406 let class_mem2 =
407 Llvm_debuginfo.dibuild_create_member_type dibuilder ~scope:namespace_di
408 ~name:"Field2" ~file:file_di ~line_number:4 ~size_in_bits:64
409 ~align_in_bits:8 ~offset_in_bits:32 flags_zero ~ty:int64_ty_di
411 stdout_metadata class_mem2;
412 (* CHECK: [[MEMB2_PTR:<0x[0-9a-f]*>]] = !DIDerivedType(tag: DW_TAG_member, name: "Field2", scope: [[NAMESPACE_PTR]], file: [[FILE_PTR]], line: 4, baseType: [[INT64TY_PTR]], size: 64, align: 8, offset: 32)
414 insist (Llvm_debuginfo.di_type_get_offset_in_bits class_mem2 = 32);
415 insist (Llvm_debuginfo.di_type_get_size_in_bits class_mem2 = 64);
416 insist (Llvm_debuginfo.di_type_get_align_in_bits class_mem2 = 8);
417 let class_elements = [| class_mem1; class_mem2 |] in
418 insist
419 ( Llvm_debuginfo.get_metadata_kind class_mem1
420 = Llvm_debuginfo.MetadataKind.DIDerivedTypeMetadataKind
421 && Llvm_debuginfo.get_metadata_kind class_mem2
422 = Llvm_debuginfo.MetadataKind.DIDerivedTypeMetadataKind );
423 stdout_metadata
424 (Llvm_debuginfo.dibuild_get_or_create_type_array dibuilder
425 ~data:class_elements);
426 (* CHECK: [[CLASSMEM_PTRS:<0x[0-9a-f]*>]] = !{[[MEMB1_PTR]], [[MEMB2_PTR]]}
428 let classty_di =
429 Llvm_debuginfo.dibuild_create_class_type dibuilder ~scope:namespace_di
430 ~name:"MyClass" ~file:file_di ~line_number:1 ~size_in_bits:96
431 ~align_in_bits:0 ~offset_in_bits:0 flags_zero ~derived_from:null_metadata
432 ~elements:class_elements ~vtable_holder:null_metadata
433 ~template_params_node:null_metadata ~unique_identifier:"MyClass"
435 stdout_metadata classty_di;
436 (* [[CLASS_PTR:<0x[0-9a-f]*>]] = !DICompositeType(tag: DW_TAG_structure_type, name: "MyClass", scope: [[NAMESPACE_PTR]], file: [[FILE_PTR]], line: 1, size: 96, elements: [[CLASSMEM_PTRS]], identifier: "MyClass")
438 insist
439 ( Llvm_debuginfo.get_metadata_kind classty_di
440 = Llvm_debuginfo.MetadataKind.DICompositeTypeMetadataKind );
443 let () =
444 let m, dibuilder, file_di, m_di = test_get_module () in
445 let fty, f, fun_di = test_get_function m dibuilder file_di m_di in
446 let () = test_bbinstr fty f fun_di file_di dibuilder in
447 let () = test_global_variable_expression dibuilder file_di m_di in
448 let () = test_variables f dibuilder file_di fun_di in
449 let () = test_types dibuilder file_di m_di in
450 Llvm_debuginfo.dibuild_finalize dibuilder;
451 ( match Llvm_analysis.verify_module m with
452 | Some err ->
453 prerr_endline ("Verification of module failed: " ^ err);
454 exit_status := 1
455 | None -> () );
456 exit !exit_status