@@ -32,9 +32,7 @@ use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
3232use super :: CodegenUnitDebugContext ;
3333use super :: namespace:: mangled_name_of_instance;
3434use 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} ;
3836use crate :: common:: { AsCCharPtr , CodegenCx } ;
3937use crate :: debuginfo:: dwarf_const;
4038use crate :: debuginfo:: metadata:: type_map:: build_type_with_children;
@@ -119,17 +117,17 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
119117 . try_to_target_usize ( cx. tcx )
120118 . expect ( "expected monomorphic const in codegen" ) as c_longlong ;
121119
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 ] ;
124122
125- let subscripts = create_DIArray ( DIB ( cx) , & [ subrange] ) ;
126123 let di_node = unsafe {
127- llvm:: LLVMRustDIBuilderCreateArrayType (
124+ llvm:: LLVMDIBuilderCreateArrayType (
128125 DIB ( cx) ,
129126 size. bits ( ) ,
130127 align. bits ( ) as u32 ,
131128 element_type_di_node,
132- subscripts,
129+ subscripts. as_ptr ( ) ,
130+ subscripts. len ( ) as c_uint ,
133131 )
134132 } ;
135133
@@ -175,17 +173,13 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
175173 "ptr_type={ptr_type}, pointee_type={pointee_type}" ,
176174 ) ;
177175
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+ ) ;
189183
190184 DINodeCreationResult { di_node, already_stored_in_typemap : false }
191185 }
@@ -233,17 +227,13 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
233227
234228 // The data pointer type is a regular, thin pointer, regardless of whether this
235229 // 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+ ) ;
247237
248238 smallvec ! [
249239 build_field_di_node(
@@ -318,7 +308,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
318308
319309 debug_context ( cx) . type_map . unique_id_to_di_node . borrow_mut ( ) . remove ( & unique_type_id) ;
320310
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[ ..] ) ;
322312
323313 // This is actually a function pointer, so wrap it in pointer DI.
324314 let name = compute_debuginfo_type_name ( cx. tcx , fn_ty, false ) ;
@@ -329,26 +319,44 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
329319 }
330320 _ => unreachable ! ( ) ,
331321 } ;
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) ;
343323
344324 DINodeCreationResult :: new ( di_node, false )
345325}
346326
347327pub ( super ) fn create_subroutine_type < ' ll > (
348328 cx : & CodegenCx < ' ll , ' _ > ,
349- signature : & ' ll DICompositeType ,
329+ signature : & [ Option < & ' ll llvm :: Metadata > ] ,
350330) -> & ' 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+ }
352360}
353361
354362/// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs
@@ -834,12 +842,13 @@ fn create_basic_type<'ll, 'tcx>(
834842 encoding : u32 ,
835843) -> & ' ll DIBasicType {
836844 unsafe {
837- llvm:: LLVMRustDIBuilderCreateBasicType (
845+ llvm:: LLVMDIBuilderCreateBasicType (
838846 DIB ( cx) ,
839- name. as_c_char_ptr ( ) ,
847+ name. as_ptr ( ) ,
840848 name. len ( ) ,
841849 size. bits ( ) ,
842850 encoding,
851+ DIFlags :: FlagZero ,
843852 )
844853 }
845854}
0 commit comments