Skip to content

Don't explicitly include upvars in the DINode produced by build_generator_variant_struct_type_di_node #107653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
let (generator_layout, state_specific_upvar_names) =
cx.tcx.generator_layout_and_saved_local_names(generator_def_id);

let common_upvar_names = cx.tcx.closure_saved_names_of_captured_variables(generator_def_id);
let variant_range = generator_substs.variant_range(generator_def_id, cx.tcx);
let variant_count = (variant_range.start.as_u32()..variant_range.end.as_u32()).len();

Expand Down Expand Up @@ -715,7 +714,6 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
generator_type_di_node,
generator_layout,
&state_specific_upvar_names,
&common_upvar_names,
);

let span = generator_layout.variant_source_info[variant_index].span;
Expand Down
30 changes: 2 additions & 28 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
generator_type_di_node: &'ll DIType,
generator_layout: &GeneratorLayout<'tcx>,
state_specific_upvar_names: &IndexVec<GeneratorSavedLocal, Option<Symbol>>,
common_upvar_names: &[String],
) -> &'ll DIType {
let variant_name = GeneratorSubsts::variant_name(variant_index);
let unique_type_id = UniqueTypeId::for_enum_variant_struct_type(
Expand All @@ -332,11 +331,6 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(

let variant_layout = generator_type_and_layout.for_variant(cx, variant_index);

let generator_substs = match generator_type_and_layout.ty.kind() {
ty::Generator(_, substs, _) => substs.as_generator(),
_ => unreachable!(),
};

type_map::build_type_with_children(
cx,
type_map::stub(
Expand All @@ -349,8 +343,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
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())
(0..variant_layout.fields.count())
.map(|field_index| {
let generator_saved_local = generator_layout.variant_fields[variant_index]
[Field::from_usize(field_index)];
Expand All @@ -372,26 +365,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
type_di_node(cx, field_type),
)
})
.collect();

// Fields that are common to all states
let common_fields: SmallVec<_> = generator_substs
.prefix_tys()
.enumerate()
.map(|(index, upvar_ty)| {
build_field_di_node(
cx,
variant_struct_type_di_node,
&common_upvar_names[index],
cx.size_and_align_of(upvar_ty),
generator_type_and_layout.fields.offset(index),
DIFlags::FlagZero,
type_di_node(cx, upvar_ty),
)
})
.collect();

state_specific_fields.into_iter().chain(common_fields.into_iter()).collect()
.collect()
},
|cx| build_generic_type_param_di_nodes(cx, generator_type_and_layout.ty),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
)
};

let common_upvar_names =
cx.tcx.closure_saved_names_of_captured_variables(generator_def_id);

// Build variant struct types
let variant_struct_type_di_nodes: SmallVec<_> = variants
.indices()
Expand Down Expand Up @@ -196,7 +193,6 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
generator_type_di_node,
generator_layout,
&state_specific_upvar_names,
&common_upvar_names,
),
source_info,
}
Expand Down