debuginfo: Get pointer size/align from tcx.data_layout instead of layout_of

This avoids some type interning and a query execution. It also just
makes the code simpler.
This commit is contained in:
Nilstrieb 2023-03-26 18:55:37 +02:00
parent 439292bc79
commit 72c917d4be

View File

@ -176,15 +176,14 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
return_if_di_node_created_in_meantime!(cx, unique_type_id); return_if_di_node_created_in_meantime!(cx, unique_type_id);
let (thin_pointer_size, thin_pointer_align) = let data_layout = &cx.tcx.data_layout;
cx.size_and_align_of(cx.tcx.mk_imm_ptr(cx.tcx.types.unit));
let ptr_type_debuginfo_name = compute_debuginfo_type_name(cx.tcx, ptr_type, true); let ptr_type_debuginfo_name = compute_debuginfo_type_name(cx.tcx, ptr_type, true);
match fat_pointer_kind(cx, pointee_type) { match fat_pointer_kind(cx, pointee_type) {
None => { None => {
// This is a thin pointer. Create a regular pointer type and give it the correct name. // This is a thin pointer. Create a regular pointer type and give it the correct name.
debug_assert_eq!( debug_assert_eq!(
(thin_pointer_size, thin_pointer_align), (data_layout.pointer_size, data_layout.pointer_align.abi),
cx.size_and_align_of(ptr_type), cx.size_and_align_of(ptr_type),
"ptr_type={}, pointee_type={}", "ptr_type={}, pointee_type={}",
ptr_type, ptr_type,
@ -195,8 +194,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
llvm::LLVMRustDIBuilderCreatePointerType( llvm::LLVMRustDIBuilderCreatePointerType(
DIB(cx), DIB(cx),
pointee_type_di_node, pointee_type_di_node,
thin_pointer_size.bits(), data_layout.pointer_size.bits(),
thin_pointer_align.bits() as u32, data_layout.pointer_align.abi.bits() as u32,
0, // Ignore DWARF address space. 0, // Ignore DWARF address space.
ptr_type_debuginfo_name.as_ptr().cast(), ptr_type_debuginfo_name.as_ptr().cast(),
ptr_type_debuginfo_name.len(), ptr_type_debuginfo_name.len(),