Skip to content

Commit 9298516

Browse files
committed
Revert "Create a safe wrapper around LLVMRustDIBuilderCreateBasicType"
This reverts commit 018032c.
1 parent 396dc31 commit 9298516

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+31-36
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use crate::debuginfo::metadata::type_map::build_type_with_children;
3939
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
4040
use crate::llvm;
4141
use crate::llvm::debuginfo::{
42-
DIBasicType, DIBuilder, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock,
43-
DIScope, DIType, DebugEmissionKind, DebugNameTableKind,
42+
DIBuilder, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType,
43+
DebugEmissionKind, DebugNameTableKind,
4444
};
4545
use crate::value::Value;
4646

@@ -491,22 +491,26 @@ pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) ->
491491
// FIXME(mw): Cache this via a regular UniqueTypeId instead of an extra field in the debug context.
492492
fn recursion_marker_type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> &'ll DIType {
493493
*debug_context(cx).recursion_marker_type.get_or_init(move || {
494-
// The choice of type here is pretty arbitrary -
495-
// anything reading the debuginfo for a recursive
496-
// type is going to see *something* weird - the only
497-
// question is what exactly it will see.
498-
//
499-
// FIXME: the name `<recur_type>` does not fit the naming scheme
500-
// of other types.
501-
//
502-
// FIXME: it might make sense to use an actual pointer type here
503-
// so that debuggers can show the address.
504-
create_basic_type(
505-
cx,
506-
"<recur_type>",
507-
cx.tcx.data_layout.pointer_size,
508-
dwarf_const::DW_ATE_unsigned,
509-
)
494+
unsafe {
495+
// The choice of type here is pretty arbitrary -
496+
// anything reading the debuginfo for a recursive
497+
// type is going to see *something* weird - the only
498+
// question is what exactly it will see.
499+
//
500+
// FIXME: the name `<recur_type>` does not fit the naming scheme
501+
// of other types.
502+
//
503+
// FIXME: it might make sense to use an actual pointer type here
504+
// so that debuggers can show the address.
505+
let name = "<recur_type>";
506+
llvm::LLVMRustDIBuilderCreateBasicType(
507+
DIB(cx),
508+
name.as_c_char_ptr(),
509+
name.len(),
510+
cx.tcx.data_layout.pointer_size.bits(),
511+
dwarf_const::DW_ATE_unsigned,
512+
)
513+
}
510514
})
511515
}
512516

@@ -784,7 +788,15 @@ fn build_basic_type_di_node<'ll, 'tcx>(
784788
_ => bug!("debuginfo::build_basic_type_di_node - `t` is invalid type"),
785789
};
786790

787-
let ty_di_node = create_basic_type(cx, name, cx.size_of(t), encoding);
791+
let ty_di_node = unsafe {
792+
llvm::LLVMRustDIBuilderCreateBasicType(
793+
DIB(cx),
794+
name.as_c_char_ptr(),
795+
name.len(),
796+
cx.size_of(t).bits(),
797+
encoding,
798+
)
799+
};
788800

789801
if !cpp_like_debuginfo {
790802
return DINodeCreationResult::new(ty_di_node, false);
@@ -812,23 +824,6 @@ fn build_basic_type_di_node<'ll, 'tcx>(
812824
DINodeCreationResult::new(typedef_di_node, false)
813825
}
814826

815-
fn create_basic_type<'ll, 'tcx>(
816-
cx: &CodegenCx<'ll, 'tcx>,
817-
name: &str,
818-
size: Size,
819-
encoding: u32,
820-
) -> &'ll DIBasicType {
821-
unsafe {
822-
llvm::LLVMRustDIBuilderCreateBasicType(
823-
DIB(cx),
824-
name.as_c_char_ptr(),
825-
name.len(),
826-
size.bits(),
827-
encoding,
828-
)
829-
}
830-
}
831-
832827
fn build_foreign_type_di_node<'ll, 'tcx>(
833828
cx: &CodegenCx<'ll, 'tcx>,
834829
t: Ty<'tcx>,

0 commit comments

Comments
 (0)