@@ -32,9 +32,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
32
32
use super :: CodegenUnitDebugContext ;
33
33
use super :: namespace:: mangled_name_of_instance;
34
34
use super :: type_names:: { compute_debuginfo_type_name, compute_debuginfo_vtable_name} ;
35
- use super :: utils:: {
36
- DIB , create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
37
- } ;
35
+ use super :: utils:: { DIB , debug_context, get_namespace_for_item, is_node_local_to_unit} ;
38
36
use crate :: common:: { AsCCharPtr , CodegenCx } ;
39
37
use crate :: debuginfo:: dwarf_const;
40
38
use crate :: debuginfo:: metadata:: type_map:: build_type_with_children;
@@ -119,17 +117,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
119
117
. try_to_target_usize ( cx. tcx )
120
118
. expect ( "expected monomorphic const in codegen" ) as c_longlong ;
121
119
122
- let subrange =
123
- unsafe { Some ( llvm :: LLVMRustDIBuilderGetOrCreateSubrange ( DIB ( cx ) , 0 , upper_bound ) ) } ;
120
+ let subrange = unsafe { llvm :: LLVMRustDIBuilderGetOrCreateSubrange ( DIB ( cx ) , 0 , upper_bound ) } ;
121
+ let subscripts = & [ subrange ] ;
124
122
125
- let subscripts = create_DIArray ( DIB ( cx) , & [ subrange] ) ;
126
123
let di_node = unsafe {
127
- llvm:: LLVMRustDIBuilderCreateArrayType (
124
+ llvm:: LLVMDIBuilderCreateArrayType (
128
125
DIB ( cx) ,
129
126
size. bits ( ) ,
130
127
align. bits ( ) as u32 ,
131
128
element_type_di_node,
132
- subscripts,
129
+ subscripts. as_ptr ( ) ,
130
+ subscripts. len ( ) as c_uint ,
133
131
)
134
132
} ;
135
133
@@ -175,17 +173,13 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
175
173
"ptr_type={ptr_type}, pointee_type={pointee_type}" ,
176
174
) ;
177
175
178
- let di_node = unsafe {
179
- llvm:: LLVMRustDIBuilderCreatePointerType (
180
- DIB ( cx) ,
181
- pointee_type_di_node,
182
- pointer_size. bits ( ) ,
183
- pointer_align. abi . bits ( ) as u32 ,
184
- 0 , // Ignore DWARF address space.
185
- ptr_type_debuginfo_name. as_c_char_ptr ( ) ,
186
- ptr_type_debuginfo_name. len ( ) ,
187
- )
188
- } ;
176
+ let di_node = create_pointer_type (
177
+ cx,
178
+ pointee_type_di_node,
179
+ pointer_size,
180
+ pointer_align. abi ,
181
+ & ptr_type_debuginfo_name,
182
+ ) ;
189
183
190
184
DINodeCreationResult { di_node, already_stored_in_typemap : false }
191
185
}
@@ -233,17 +227,13 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
233
227
234
228
// The data pointer type is a regular, thin pointer, regardless of whether this
235
229
// is a slice or a trait object.
236
- let data_ptr_type_di_node = unsafe {
237
- llvm:: LLVMRustDIBuilderCreatePointerType (
238
- DIB ( cx) ,
239
- pointee_type_di_node,
240
- addr_field. size . bits ( ) ,
241
- addr_field. align . abi . bits ( ) as u32 ,
242
- 0 , // Ignore DWARF address space.
243
- std:: ptr:: null ( ) ,
244
- 0 ,
245
- )
246
- } ;
230
+ let data_ptr_type_di_node = create_pointer_type (
231
+ cx,
232
+ pointee_type_di_node,
233
+ addr_field. size ,
234
+ addr_field. align . abi ,
235
+ "" ,
236
+ ) ;
247
237
248
238
smallvec ! [
249
239
build_field_di_node(
@@ -318,7 +308,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
318
308
319
309
debug_context ( cx) . type_map . unique_id_to_di_node . borrow_mut ( ) . remove ( & unique_type_id) ;
320
310
321
- let fn_di_node = create_subroutine_type ( cx, create_DIArray ( DIB ( cx ) , & signature_di_nodes[ ..] ) ) ;
311
+ let fn_di_node = create_subroutine_type ( cx, & signature_di_nodes[ ..] ) ;
322
312
323
313
// This is actually a function pointer, so wrap it in pointer DI.
324
314
let name = compute_debuginfo_type_name ( cx. tcx , fn_ty, false ) ;
@@ -329,26 +319,44 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
329
319
}
330
320
_ => unreachable ! ( ) ,
331
321
} ;
332
- let di_node = unsafe {
333
- llvm:: LLVMRustDIBuilderCreatePointerType (
334
- DIB ( cx) ,
335
- fn_di_node,
336
- size. bits ( ) ,
337
- align. bits ( ) as u32 ,
338
- 0 , // Ignore DWARF address space.
339
- name. as_c_char_ptr ( ) ,
340
- name. len ( ) ,
341
- )
342
- } ;
322
+ let di_node = create_pointer_type ( cx, fn_di_node, size, align, & name) ;
343
323
344
324
DINodeCreationResult :: new ( di_node, false )
345
325
}
346
326
347
327
pub ( super ) fn create_subroutine_type < ' ll > (
348
328
cx : & CodegenCx < ' ll , ' _ > ,
349
- signature : & ' ll DICompositeType ,
329
+ signature : & [ Option < & ' ll llvm :: Metadata > ] ,
350
330
) -> & ' ll DICompositeType {
351
- unsafe { llvm:: LLVMRustDIBuilderCreateSubroutineType ( DIB ( cx) , signature) }
331
+ unsafe {
332
+ llvm:: LLVMDIBuilderCreateSubroutineType (
333
+ DIB ( cx) ,
334
+ None , // ("File" is ignored and has no effect)
335
+ signature. as_ptr ( ) ,
336
+ signature. len ( ) as c_uint ,
337
+ DIFlags :: FlagZero , // (default value)
338
+ )
339
+ }
340
+ }
341
+
342
+ fn create_pointer_type < ' ll > (
343
+ cx : & CodegenCx < ' ll , ' _ > ,
344
+ pointee_ty : & ' ll llvm:: Metadata ,
345
+ size : Size ,
346
+ align : Align ,
347
+ name : & str ,
348
+ ) -> & ' ll llvm:: Metadata {
349
+ unsafe {
350
+ llvm:: LLVMDIBuilderCreatePointerType (
351
+ DIB ( cx) ,
352
+ pointee_ty,
353
+ size. bits ( ) ,
354
+ align. bits ( ) as u32 ,
355
+ 0 , // Ignore DWARF address space.
356
+ name. as_ptr ( ) ,
357
+ name. len ( ) ,
358
+ )
359
+ }
352
360
}
353
361
354
362
/// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs
@@ -834,12 +842,13 @@ fn create_basic_type<'ll, 'tcx>(
834
842
encoding : u32 ,
835
843
) -> & ' ll DIBasicType {
836
844
unsafe {
837
- llvm:: LLVMRustDIBuilderCreateBasicType (
845
+ llvm:: LLVMDIBuilderCreateBasicType (
838
846
DIB ( cx) ,
839
- name. as_c_char_ptr ( ) ,
847
+ name. as_ptr ( ) ,
840
848
name. len ( ) ,
841
849
size. bits ( ) ,
842
850
encoding,
851
+ DIFlags :: FlagZero ,
843
852
)
844
853
}
845
854
}
0 commit comments