summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_llvm/src/debuginfo
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /compiler/rustc_codegen_llvm/src/debuginfo
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs5
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs142
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs90
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs50
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs74
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs2
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/mod.rs7
7 files changed, 209 insertions, 161 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs
index aff764f02..6a63eda4b 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs
@@ -75,7 +75,10 @@ fn make_mir_scope<'ll, 'tcx>(
return;
};
- if let Some(vars) = variables && !vars.contains(scope) && scope_data.inlined.is_none() {
+ if let Some(vars) = variables
+ && !vars.contains(scope)
+ && scope_data.inlined.is_none()
+ {
// Do not create a DIScope if there are no variables defined in this
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
debug_context.scopes[scope] = parent_scope;
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index ed9387616..865bf01c8 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -335,12 +335,20 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
// This is actually a function pointer, so wrap it in pointer DI.
let name = compute_debuginfo_type_name(cx.tcx, fn_ty, false);
+ let (size, align) = match fn_ty.kind() {
+ ty::FnDef(..) => (0, 1),
+ ty::FnPtr(..) => (
+ cx.tcx.data_layout.pointer_size.bits(),
+ cx.tcx.data_layout.pointer_align.abi.bits() as u32,
+ ),
+ _ => unreachable!(),
+ };
let di_node = unsafe {
llvm::LLVMRustDIBuilderCreatePointerType(
DIB(cx),
fn_di_node,
- cx.tcx.data_layout.pointer_size.bits(),
- cx.tcx.data_layout.pointer_align.abi.bits() as u32,
+ size,
+ align,
0, // Ignore DWARF address space.
name.as_ptr().cast(),
name.len(),
@@ -452,7 +460,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
}
ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
- ty::Generator(..) => enums::build_generator_di_node(cx, unique_type_id),
+ ty::Coroutine(..) => enums::build_coroutine_di_node(cx, unique_type_id),
ty::Adt(def, ..) => match def.adt_kind() {
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id),
AdtKind::Union => build_union_type_di_node(cx, unique_type_id),
@@ -539,48 +547,77 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
) -> &'ll DIFile {
debug!(?source_file.name);
+ use rustc_session::RemapFileNameExt;
let (directory, file_name) = match &source_file.name {
FileName::Real(filename) => {
let working_directory = &cx.sess().opts.working_dir;
debug!(?working_directory);
- let filename = cx
- .sess()
- .source_map()
- .path_mapping()
- .to_embeddable_absolute_path(filename.clone(), working_directory);
-
- // Construct the absolute path of the file
- let abs_path = filename.remapped_path_if_available();
- debug!(?abs_path);
-
- if let Ok(rel_path) =
- abs_path.strip_prefix(working_directory.remapped_path_if_available())
- {
- // If the compiler's working directory (which also is the DW_AT_comp_dir of
- // the compilation unit) is a prefix of the path we are about to emit, then
- // only emit the part relative to the working directory.
- // Because of path remapping we sometimes see strange things here: `abs_path`
- // might actually look like a relative path
- // (e.g. `<crate-name-and-version>/src/lib.rs`), so if we emit it without
- // taking the working directory into account, downstream tooling will
- // interpret it as `<working-directory>/<crate-name-and-version>/src/lib.rs`,
- // which makes no sense. Usually in such cases the working directory will also
- // be remapped to `<crate-name-and-version>` or some other prefix of the path
- // we are remapping, so we end up with
- // `<crate-name-and-version>/<crate-name-and-version>/src/lib.rs`.
- // By moving the working directory portion into the `directory` part of the
- // DIFile, we allow LLVM to emit just the relative path for DWARF, while
- // still emitting the correct absolute path for CodeView.
- (
- working_directory.to_string_lossy(FileNameDisplayPreference::Remapped),
- rel_path.to_string_lossy().into_owned(),
- )
+ if cx.sess().should_prefer_remapped_for_codegen() {
+ let filename = cx
+ .sess()
+ .source_map()
+ .path_mapping()
+ .to_embeddable_absolute_path(filename.clone(), working_directory);
+
+ // Construct the absolute path of the file
+ let abs_path = filename.remapped_path_if_available();
+ debug!(?abs_path);
+
+ if let Ok(rel_path) =
+ abs_path.strip_prefix(working_directory.remapped_path_if_available())
+ {
+ // If the compiler's working directory (which also is the DW_AT_comp_dir of
+ // the compilation unit) is a prefix of the path we are about to emit, then
+ // only emit the part relative to the working directory.
+ // Because of path remapping we sometimes see strange things here: `abs_path`
+ // might actually look like a relative path
+ // (e.g. `<crate-name-and-version>/src/lib.rs`), so if we emit it without
+ // taking the working directory into account, downstream tooling will
+ // interpret it as `<working-directory>/<crate-name-and-version>/src/lib.rs`,
+ // which makes no sense. Usually in such cases the working directory will also
+ // be remapped to `<crate-name-and-version>` or some other prefix of the path
+ // we are remapping, so we end up with
+ // `<crate-name-and-version>/<crate-name-and-version>/src/lib.rs`.
+ // By moving the working directory portion into the `directory` part of the
+ // DIFile, we allow LLVM to emit just the relative path for DWARF, while
+ // still emitting the correct absolute path for CodeView.
+ (
+ working_directory.to_string_lossy(FileNameDisplayPreference::Remapped),
+ rel_path.to_string_lossy().into_owned(),
+ )
+ } else {
+ ("".into(), abs_path.to_string_lossy().into_owned())
+ }
} else {
- ("".into(), abs_path.to_string_lossy().into_owned())
+ let working_directory = working_directory.local_path_if_available();
+ let filename = filename.local_path_if_available();
+
+ debug!(?working_directory, ?filename);
+
+ let abs_path: Cow<'_, Path> = if filename.is_absolute() {
+ filename.into()
+ } else {
+ let mut p = PathBuf::new();
+ p.push(working_directory);
+ p.push(filename);
+ p.into()
+ };
+
+ if let Ok(rel_path) = abs_path.strip_prefix(working_directory) {
+ (
+ working_directory.to_string_lossy().into(),
+ rel_path.to_string_lossy().into_owned(),
+ )
+ } else {
+ ("".into(), abs_path.to_string_lossy().into_owned())
+ }
}
}
- other => ("".into(), other.prefer_remapped().to_string_lossy().into_owned()),
+ other => {
+ debug!(?other);
+ ("".into(), other.for_codegen(cx.sess()).to_string_lossy().into_owned())
+ }
};
let hash_kind = match source_file.src_hash.kind {
@@ -814,8 +851,9 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
let producer = format!("clang LLVM ({rustc_producer})");
+ use rustc_session::RemapFileNameExt;
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
- let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
+ let work_dir = tcx.sess.opts.working_dir.for_codegen(&tcx.sess).to_string_lossy();
let flags = "\0";
let output_filenames = tcx.output_filenames(());
let split_name = if tcx.sess.target_can_use_split_dwarf() {
@@ -826,7 +864,13 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
Some(codegen_unit_name),
)
// We get a path relative to the working directory from split_dwarf_path
- .map(|f| tcx.sess.source_map().path_mapping().map_prefix(f).0)
+ .map(|f| {
+ if tcx.sess.should_prefer_remapped_for_split_debuginfo_paths() {
+ tcx.sess.source_map().path_mapping().map_prefix(f).0
+ } else {
+ f.into()
+ }
+ })
} else {
None
}
@@ -982,20 +1026,20 @@ fn build_struct_type_di_node<'ll, 'tcx>(
// Tuples
//=-----------------------------------------------------------------------------
-/// Builds the DW_TAG_member debuginfo nodes for the upvars of a closure or generator.
-/// For a generator, this will handle upvars shared by all states.
+/// Builds the DW_TAG_member debuginfo nodes for the upvars of a closure or coroutine.
+/// For a coroutine, this will handle upvars shared by all states.
fn build_upvar_field_di_nodes<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
- closure_or_generator_ty: Ty<'tcx>,
- closure_or_generator_di_node: &'ll DIType,
+ closure_or_coroutine_ty: Ty<'tcx>,
+ closure_or_coroutine_di_node: &'ll DIType,
) -> SmallVec<&'ll DIType> {
- let (&def_id, up_var_tys) = match closure_or_generator_ty.kind() {
- ty::Generator(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
+ let (&def_id, up_var_tys) = match closure_or_coroutine_ty.kind() {
+ ty::Coroutine(def_id, args, _) => (def_id, args.as_coroutine().prefix_tys()),
ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()),
_ => {
bug!(
- "build_upvar_field_di_nodes() called with non-closure-or-generator-type: {:?}",
- closure_or_generator_ty
+ "build_upvar_field_di_nodes() called with non-closure-or-coroutine-type: {:?}",
+ closure_or_coroutine_ty
)
}
};
@@ -1005,7 +1049,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
);
let capture_names = cx.tcx.closure_saved_names_of_captured_variables(def_id);
- let layout = cx.layout_of(closure_or_generator_ty);
+ let layout = cx.layout_of(closure_or_coroutine_ty);
up_var_tys
.into_iter()
@@ -1014,7 +1058,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
.map(|(index, (up_var_ty, capture_name))| {
build_field_di_node(
cx,
- closure_or_generator_di_node,
+ closure_or_coroutine_di_node,
capture_name.as_str(),
cx.size_and_align_of(up_var_ty),
layout.fields.offset(index),
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs
index 88040557a..ca7bfbeac 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs
@@ -12,7 +12,7 @@ use rustc_middle::{
ty::{
self,
layout::{LayoutOf, TyAndLayout},
- AdtDef, GeneratorArgs, Ty,
+ AdtDef, CoroutineArgs, Ty,
},
};
use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
@@ -268,18 +268,18 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
)
}
-/// A generator debuginfo node looks the same as a that of an enum type.
+/// A coroutine debuginfo node looks the same as a that of an enum type.
///
/// See [build_enum_type_di_node] for more information.
-pub(super) fn build_generator_di_node<'ll, 'tcx>(
+pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
- let generator_type = unique_type_id.expect_ty();
- let generator_type_and_layout = cx.layout_of(generator_type);
- let generator_type_name = compute_debuginfo_type_name(cx.tcx, generator_type, false);
+ let coroutine_type = unique_type_id.expect_ty();
+ let coroutine_type_and_layout = cx.layout_of(coroutine_type);
+ let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
- debug_assert!(!wants_c_like_enum_debuginfo(generator_type_and_layout));
+ debug_assert!(!wants_c_like_enum_debuginfo(coroutine_type_and_layout));
type_map::build_type_with_children(
cx,
@@ -287,24 +287,24 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
cx,
type_map::Stub::Union,
unique_type_id,
- &generator_type_name,
- size_and_align_of(generator_type_and_layout),
+ &coroutine_type_name,
+ size_and_align_of(coroutine_type_and_layout),
NO_SCOPE_METADATA,
DIFlags::FlagZero,
),
- |cx, generator_type_di_node| match generator_type_and_layout.variants {
+ |cx, coroutine_type_di_node| match coroutine_type_and_layout.variants {
Variants::Multiple { tag_encoding: TagEncoding::Direct, .. } => {
- build_union_fields_for_direct_tag_generator(
+ build_union_fields_for_direct_tag_coroutine(
cx,
- generator_type_and_layout,
- generator_type_di_node,
+ coroutine_type_and_layout,
+ coroutine_type_di_node,
)
}
Variants::Single { .. }
| Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, .. } => {
bug!(
- "Encountered generator with non-direct-tag layout: {:?}",
- generator_type_and_layout
+ "Encountered coroutine with non-direct-tag layout: {:?}",
+ coroutine_type_and_layout
)
}
},
@@ -428,7 +428,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
})
.collect();
- build_union_fields_for_direct_tag_enum_or_generator(
+ build_union_fields_for_direct_tag_enum_or_coroutine(
cx,
enum_type_and_layout,
enum_type_di_node,
@@ -469,8 +469,8 @@ fn build_variant_names_type_di_node<'ll, 'tcx>(
fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
- enum_or_generator_type_and_layout: TyAndLayout<'tcx>,
- enum_or_generator_type_di_node: &'ll DIType,
+ enum_or_coroutine_type_and_layout: TyAndLayout<'tcx>,
+ enum_or_coroutine_type_di_node: &'ll DIType,
variant_index: VariantIdx,
untagged_variant_index: Option<VariantIdx>,
variant_struct_type_di_node: &'ll DIType,
@@ -486,13 +486,13 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
Stub::Struct,
UniqueTypeId::for_enum_variant_struct_type_wrapper(
cx.tcx,
- enum_or_generator_type_and_layout.ty,
+ enum_or_coroutine_type_and_layout.ty,
variant_index,
),
&variant_struct_wrapper_type_name(variant_index),
// NOTE: We use size and align of enum_type, not from variant_layout:
- size_and_align_of(enum_or_generator_type_and_layout),
- Some(enum_or_generator_type_di_node),
+ size_and_align_of(enum_or_coroutine_type_and_layout),
+ Some(enum_or_coroutine_type_di_node),
DIFlags::FlagZero,
),
|cx, wrapper_struct_type_di_node| {
@@ -535,7 +535,7 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
cx,
wrapper_struct_type_di_node,
"value",
- size_and_align_of(enum_or_generator_type_and_layout),
+ size_and_align_of(enum_or_coroutine_type_and_layout),
Size::ZERO,
DIFlags::FlagZero,
variant_struct_type_di_node,
@@ -662,40 +662,40 @@ fn split_128(value: u128) -> Split128 {
Split128 { hi: (value >> 64) as u64, lo: value as u64 }
}
-fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
+fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
- generator_type_and_layout: TyAndLayout<'tcx>,
- generator_type_di_node: &'ll DIType,
+ coroutine_type_and_layout: TyAndLayout<'tcx>,
+ coroutine_type_di_node: &'ll DIType,
) -> SmallVec<&'ll DIType> {
let Variants::Multiple { tag_encoding: TagEncoding::Direct, tag_field, .. } =
- generator_type_and_layout.variants
+ coroutine_type_and_layout.variants
else {
bug!("This function only supports layouts with directly encoded tags.")
};
- let (generator_def_id, generator_args) = match generator_type_and_layout.ty.kind() {
- &ty::Generator(def_id, args, _) => (def_id, args.as_generator()),
+ let (coroutine_def_id, coroutine_args) = match coroutine_type_and_layout.ty.kind() {
+ &ty::Coroutine(def_id, args, _) => (def_id, args.as_coroutine()),
_ => unreachable!(),
};
- let generator_layout = cx.tcx.optimized_mir(generator_def_id).generator_layout().unwrap();
+ let coroutine_layout = cx.tcx.optimized_mir(coroutine_def_id).coroutine_layout().unwrap();
- let common_upvar_names = cx.tcx.closure_saved_names_of_captured_variables(generator_def_id);
- let variant_range = generator_args.variant_range(generator_def_id, cx.tcx);
+ let common_upvar_names = cx.tcx.closure_saved_names_of_captured_variables(coroutine_def_id);
+ let variant_range = coroutine_args.variant_range(coroutine_def_id, cx.tcx);
let variant_count = (variant_range.start.as_u32()..variant_range.end.as_u32()).len();
- let tag_base_type = tag_base_type(cx, generator_type_and_layout);
+ let tag_base_type = tag_base_type(cx, coroutine_type_and_layout);
let variant_names_type_di_node = build_variant_names_type_di_node(
cx,
- generator_type_di_node,
+ coroutine_type_di_node,
variant_range
.clone()
- .map(|variant_index| (variant_index, GeneratorArgs::variant_name(variant_index))),
+ .map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))),
);
let discriminants: IndexVec<VariantIdx, DiscrResult> = {
- let discriminants_iter = generator_args.discriminants(generator_def_id, cx.tcx);
+ let discriminants_iter = coroutine_args.discriminants(coroutine_def_id, cx.tcx);
let mut discriminants: IndexVec<VariantIdx, DiscrResult> =
IndexVec::with_capacity(variant_count);
for (variant_index, discr) in discriminants_iter {
@@ -709,16 +709,16 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
// Build the type node for each field.
let variant_field_infos: SmallVec<VariantFieldInfo<'ll>> = variant_range
.map(|variant_index| {
- let variant_struct_type_di_node = super::build_generator_variant_struct_type_di_node(
+ let variant_struct_type_di_node = super::build_coroutine_variant_struct_type_di_node(
cx,
variant_index,
- generator_type_and_layout,
- generator_type_di_node,
- generator_layout,
+ coroutine_type_and_layout,
+ coroutine_type_di_node,
+ coroutine_layout,
&common_upvar_names,
);
- let span = generator_layout.variant_source_info[variant_index].span;
+ let span = coroutine_layout.variant_source_info[variant_index].span;
let source_info = if !span.is_dummy() {
let loc = cx.lookup_debug_loc(span.lo());
Some((file_metadata(cx, &loc.file), loc.line as c_uint))
@@ -735,10 +735,10 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
})
.collect();
- build_union_fields_for_direct_tag_enum_or_generator(
+ build_union_fields_for_direct_tag_enum_or_coroutine(
cx,
- generator_type_and_layout,
- generator_type_di_node,
+ coroutine_type_and_layout,
+ coroutine_type_di_node,
&variant_field_infos[..],
variant_names_type_di_node,
tag_base_type,
@@ -747,9 +747,9 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
)
}
-/// This is a helper function shared between enums and generators that makes sure fields have the
+/// This is a helper function shared between enums and coroutines that makes sure fields have the
/// expect names.
-fn build_union_fields_for_direct_tag_enum_or_generator<'ll, 'tcx>(
+fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
enum_type_and_layout: TyAndLayout<'tcx>,
enum_type_di_node: &'ll DIType,
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
index d3239d5c3..df1df6d19 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
@@ -6,11 +6,11 @@ use rustc_hir::def::CtorKind;
use rustc_index::IndexSlice;
use rustc_middle::{
bug,
- mir::GeneratorLayout,
+ mir::CoroutineLayout,
ty::{
self,
layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout},
- AdtDef, GeneratorArgs, Ty, VariantDef,
+ AdtDef, CoroutineArgs, Ty, VariantDef,
},
};
use rustc_span::Symbol;
@@ -66,14 +66,14 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
}
}
-pub(super) fn build_generator_di_node<'ll, 'tcx>(
+pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
if cpp_like_debuginfo(cx.tcx) {
- cpp_like::build_generator_di_node(cx, unique_type_id)
+ cpp_like::build_coroutine_di_node(cx, unique_type_id)
} else {
- native::build_generator_di_node(cx, unique_type_id)
+ native::build_coroutine_di_node(cx, unique_type_id)
}
}
@@ -101,13 +101,13 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
}
}
-/// Extract the type with which we want to describe the tag of the given enum or generator.
+/// Extract the type with which we want to describe the tag of the given enum or coroutine.
fn tag_base_type<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
enum_type_and_layout: TyAndLayout<'tcx>,
) -> Ty<'tcx> {
debug_assert!(match enum_type_and_layout.ty.kind() {
- ty::Generator(..) => true,
+ ty::Coroutine(..) => true,
ty::Adt(adt_def, _) => adt_def.is_enum(),
_ => false,
});
@@ -300,8 +300,8 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
.di_node
}
-/// Build the struct type for describing a single generator state.
-/// See [build_generator_variant_struct_type_di_node].
+/// Build the struct type for describing a single coroutine state.
+/// See [build_coroutine_variant_struct_type_di_node].
///
/// ```txt
///
@@ -317,25 +317,25 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
/// ---> DW_TAG_structure_type (type of variant 3)
///
/// ```
-pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
+pub fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
variant_index: VariantIdx,
- generator_type_and_layout: TyAndLayout<'tcx>,
- generator_type_di_node: &'ll DIType,
- generator_layout: &GeneratorLayout<'tcx>,
+ coroutine_type_and_layout: TyAndLayout<'tcx>,
+ coroutine_type_di_node: &'ll DIType,
+ coroutine_layout: &CoroutineLayout<'tcx>,
common_upvar_names: &IndexSlice<FieldIdx, Symbol>,
) -> &'ll DIType {
- let variant_name = GeneratorArgs::variant_name(variant_index);
+ let variant_name = CoroutineArgs::variant_name(variant_index);
let unique_type_id = UniqueTypeId::for_enum_variant_struct_type(
cx.tcx,
- generator_type_and_layout.ty,
+ coroutine_type_and_layout.ty,
variant_index,
);
- let variant_layout = generator_type_and_layout.for_variant(cx, variant_index);
+ let variant_layout = coroutine_type_and_layout.for_variant(cx, variant_index);
- let generator_args = match generator_type_and_layout.ty.kind() {
- ty::Generator(_, args, _) => args.as_generator(),
+ let coroutine_args = match coroutine_type_and_layout.ty.kind() {
+ ty::Coroutine(_, args, _) => args.as_coroutine(),
_ => unreachable!(),
};
@@ -346,17 +346,17 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
Stub::Struct,
unique_type_id,
&variant_name,
- size_and_align_of(generator_type_and_layout),
- Some(generator_type_di_node),
+ size_and_align_of(coroutine_type_and_layout),
+ Some(coroutine_type_di_node),
DIFlags::FlagZero,
),
|cx, variant_struct_type_di_node| {
// Fields that just belong to this variant/state
let state_specific_fields: SmallVec<_> = (0..variant_layout.fields.count())
.map(|field_index| {
- let generator_saved_local = generator_layout.variant_fields[variant_index]
+ let coroutine_saved_local = coroutine_layout.variant_fields[variant_index]
[FieldIdx::from_usize(field_index)];
- let field_name_maybe = generator_layout.field_names[generator_saved_local];
+ let field_name_maybe = coroutine_layout.field_names[coroutine_saved_local];
let field_name = field_name_maybe
.as_ref()
.map(|s| Cow::from(s.as_str()))
@@ -377,7 +377,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
.collect();
// Fields that are common to all states
- let common_fields: SmallVec<_> = generator_args
+ let common_fields: SmallVec<_> = coroutine_args
.prefix_tys()
.iter()
.zip(common_upvar_names)
@@ -388,7 +388,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
variant_struct_type_di_node,
upvar_name.as_str(),
cx.size_and_align_of(upvar_ty),
- generator_type_and_layout.fields.offset(index),
+ coroutine_type_and_layout.fields.offset(index),
DIFlags::FlagZero,
type_di_node(cx, upvar_ty),
)
@@ -397,7 +397,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
state_specific_fields.into_iter().chain(common_fields.into_iter()).collect()
},
- |cx| build_generic_type_param_di_nodes(cx, generator_type_and_layout.ty),
+ |cx| build_generic_type_param_di_nodes(cx, coroutine_type_and_layout.ty),
)
.di_node
}
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
index feac40d8c..7eff52b85 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
@@ -110,12 +110,12 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
)
}
-/// Build the debuginfo node for a generator environment. It looks the same as the debuginfo for
+/// Build the debuginfo node for a coroutine environment. It looks the same as the debuginfo for
/// an enum. See [build_enum_type_di_node] for more information.
///
/// ```txt
///
-/// ---> DW_TAG_structure_type (top-level type for the generator)
+/// ---> DW_TAG_structure_type (top-level type for the coroutine)
/// DW_TAG_variant_part (variant part)
/// DW_AT_discr (reference to discriminant DW_TAG_member)
/// DW_TAG_member (discriminant member)
@@ -127,21 +127,21 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
/// DW_TAG_structure_type (type of variant 3)
///
/// ```
-pub(super) fn build_generator_di_node<'ll, 'tcx>(
+pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
- let generator_type = unique_type_id.expect_ty();
- let &ty::Generator(generator_def_id, _, _) = generator_type.kind() else {
- bug!("build_generator_di_node() called with non-generator type: `{:?}`", generator_type)
+ let coroutine_type = unique_type_id.expect_ty();
+ let &ty::Coroutine(coroutine_def_id, _, _) = coroutine_type.kind() else {
+ bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type)
};
- let containing_scope = get_namespace_for_item(cx, generator_def_id);
- let generator_type_and_layout = cx.layout_of(generator_type);
+ let containing_scope = get_namespace_for_item(cx, coroutine_def_id);
+ let coroutine_type_and_layout = cx.layout_of(coroutine_type);
- debug_assert!(!wants_c_like_enum_debuginfo(generator_type_and_layout));
+ debug_assert!(!wants_c_like_enum_debuginfo(coroutine_type_and_layout));
- let generator_type_name = compute_debuginfo_type_name(cx.tcx, generator_type, false);
+ let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
type_map::build_type_with_children(
cx,
@@ -149,37 +149,37 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
cx,
Stub::Struct,
unique_type_id,
- &generator_type_name,
- size_and_align_of(generator_type_and_layout),
+ &coroutine_type_name,
+ size_and_align_of(coroutine_type_and_layout),
Some(containing_scope),
DIFlags::FlagZero,
),
- |cx, generator_type_di_node| {
- let generator_layout =
- cx.tcx.optimized_mir(generator_def_id).generator_layout().unwrap();
+ |cx, coroutine_type_di_node| {
+ let coroutine_layout =
+ cx.tcx.optimized_mir(coroutine_def_id).coroutine_layout().unwrap();
let Variants::Multiple { tag_encoding: TagEncoding::Direct, ref variants, .. } =
- generator_type_and_layout.variants
+ coroutine_type_and_layout.variants
else {
bug!(
- "Encountered generator with non-direct-tag layout: {:?}",
- generator_type_and_layout
+ "Encountered coroutine with non-direct-tag layout: {:?}",
+ coroutine_type_and_layout
)
};
let common_upvar_names =
- cx.tcx.closure_saved_names_of_captured_variables(generator_def_id);
+ cx.tcx.closure_saved_names_of_captured_variables(coroutine_def_id);
// Build variant struct types
let variant_struct_type_di_nodes: SmallVec<_> = variants
.indices()
.map(|variant_index| {
// FIXME: This is problematic because just a number is not a valid identifier.
- // GeneratorArgs::variant_name(variant_index), would be consistent
+ // CoroutineArgs::variant_name(variant_index), would be consistent
// with enums?
let variant_name = format!("{}", variant_index.as_usize()).into();
- let span = generator_layout.variant_source_info[variant_index].span;
+ let span = coroutine_layout.variant_source_info[variant_index].span;
let source_info = if !span.is_dummy() {
let loc = cx.lookup_debug_loc(span.lo());
Some((file_metadata(cx, &loc.file), loc.line))
@@ -191,12 +191,12 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
variant_index,
variant_name,
variant_struct_type_di_node:
- super::build_generator_variant_struct_type_di_node(
+ super::build_coroutine_variant_struct_type_di_node(
cx,
variant_index,
- generator_type_and_layout,
- generator_type_di_node,
- generator_layout,
+ coroutine_type_and_layout,
+ coroutine_type_di_node,
+ coroutine_layout,
&common_upvar_names,
),
source_info,
@@ -206,18 +206,18 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
smallvec![build_enum_variant_part_di_node(
cx,
- generator_type_and_layout,
- generator_type_di_node,
+ coroutine_type_and_layout,
+ coroutine_type_di_node,
&variant_struct_type_di_nodes[..],
)]
},
- // We don't seem to be emitting generic args on the generator type, it seems. Rather
+ // We don't seem to be emitting generic args on the coroutine type, it seems. Rather
// they get attached to the struct type of each variant.
NO_GENERICS,
)
}
-/// Builds the DW_TAG_variant_part of an enum or generator debuginfo node:
+/// Builds the DW_TAG_variant_part of an enum or coroutine debuginfo node:
///
/// ```txt
/// DW_TAG_structure_type (top-level type for enum)
@@ -306,11 +306,11 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
/// ```
fn build_discr_member_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
- enum_or_generator_type_and_layout: TyAndLayout<'tcx>,
- enum_or_generator_type_di_node: &'ll DIType,
+ enum_or_coroutine_type_and_layout: TyAndLayout<'tcx>,
+ enum_or_coroutine_type_di_node: &'ll DIType,
) -> Option<&'ll DIType> {
- let tag_name = match enum_or_generator_type_and_layout.ty.kind() {
- ty::Generator(..) => "__state",
+ let tag_name = match enum_or_coroutine_type_and_layout.ty.kind() {
+ ty::Coroutine(..) => "__state",
_ => "",
};
@@ -320,14 +320,14 @@ fn build_discr_member_di_node<'ll, 'tcx>(
// In LLVM IR the wrong scope will be listed but when DWARF is
// generated from it, the DW_TAG_member will be a child the
// DW_TAG_variant_part.
- let containing_scope = enum_or_generator_type_di_node;
+ let containing_scope = enum_or_coroutine_type_di_node;
- match enum_or_generator_type_and_layout.layout.variants() {
+ match enum_or_coroutine_type_and_layout.layout.variants() {
// A single-variant enum has no discriminant.
&Variants::Single { .. } => None,
&Variants::Multiple { tag_field, .. } => {
- let tag_base_type = tag_base_type(cx, enum_or_generator_type_and_layout);
+ let tag_base_type = tag_base_type(cx, enum_or_coroutine_type_and_layout);
let (size, align) = cx.size_and_align_of(tag_base_type);
unsafe {
@@ -340,7 +340,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
UNKNOWN_LINE_NUMBER,
size.bits(),
align.bits() as u32,
- enum_or_generator_type_and_layout.fields.offset(tag_field).bits(),
+ enum_or_coroutine_type_and_layout.fields.offset(tag_field).bits(),
DIFlags::FlagArtificial,
type_di_node(cx, tag_base_type),
))
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs
index e30622cbd..1aec65cf9 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs
@@ -43,7 +43,7 @@ pub(super) enum UniqueTypeId<'tcx> {
/// The ID of a regular type as it shows up at the language level.
Ty(Ty<'tcx>, private::HiddenZst),
/// The ID for the single DW_TAG_variant_part nested inside the top-level
- /// DW_TAG_structure_type that describes enums and generators.
+ /// DW_TAG_structure_type that describes enums and coroutines.
VariantPart(Ty<'tcx>, private::HiddenZst),
/// The ID for the artificial struct type describing a single enum variant.
VariantStructType(Ty<'tcx>, VariantIdx, private::HiddenZst),
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
index 30cc9ea9b..4832b147a 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
@@ -50,7 +50,6 @@ mod utils;
pub use self::create_scope_map::compute_mir_scopes;
pub use self::metadata::build_global_var_di_node;
-pub use self::metadata::extend_scope_to_file;
#[allow(non_upper_case_globals)]
const DW_TAG_auto_variable: c_uint = 0x100;
@@ -342,7 +341,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
// We look up the generics of the enclosing function and truncate the args
// to their length in order to cut off extra stuff that might be in there for
- // closures or generators.
+ // closures or coroutines.
let generics = tcx.generics_of(enclosing_fn_def_id);
let args = instance.args.truncate_to(tcx, generics);
@@ -537,7 +536,9 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
// Only "class" methods are generally understood by LLVM,
// so avoid methods on other types (e.g., `<*mut T>::null`).
- if let ty::Adt(def, ..) = impl_self_ty.kind() && !def.is_box() {
+ if let ty::Adt(def, ..) = impl_self_ty.kind()
+ && !def.is_box()
+ {
// Again, only create type information if full debuginfo is enabled
if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.has_param()
{