Auto merge of #139878 - petrochenkov:revllvmclean2, r=compiler-errors
Revert "Deduplicate template parameter creation"
This reverts commit 6adc2c1fd6
.
More precise subset of https://github.com/rust-lang/rust/pull/139874.
This commit is contained in:
commit
cacb9eed38
3 changed files with 45 additions and 26 deletions
|
@ -1315,31 +1315,21 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>(
|
|||
ty: Ty<'tcx>,
|
||||
) -> SmallVec<Option<&'ll DIType>> {
|
||||
if let ty::Adt(def, args) = *ty.kind() {
|
||||
let generics = cx.tcx.generics_of(def.did());
|
||||
return get_template_parameters(cx, generics, args);
|
||||
}
|
||||
|
||||
return smallvec![];
|
||||
}
|
||||
|
||||
pub(super) fn get_template_parameters<'ll, 'tcx>(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
generics: &ty::Generics,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> SmallVec<Option<&'ll DIType>> {
|
||||
if args.types().next().is_some() {
|
||||
let names = get_parameter_names(cx, generics);
|
||||
let template_params: SmallVec<_> = iter::zip(args, names)
|
||||
.filter_map(|(kind, name)| {
|
||||
kind.as_type().map(|ty| {
|
||||
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
|
||||
let actual_type_di_node = type_di_node(cx, actual_type);
|
||||
Some(cx.create_template_type_parameter(name.as_str(), actual_type_di_node))
|
||||
if args.types().next().is_some() {
|
||||
let generics = cx.tcx.generics_of(def.did());
|
||||
let names = get_parameter_names(cx, generics);
|
||||
let template_params: SmallVec<_> = iter::zip(args, names)
|
||||
.filter_map(|(kind, name)| {
|
||||
kind.as_type().map(|ty| {
|
||||
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
|
||||
let actual_type_di_node = type_di_node(cx, actual_type);
|
||||
Some(cx.create_template_type_parameter(name.as_str(), actual_type_di_node))
|
||||
})
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
.collect();
|
||||
|
||||
return template_params;
|
||||
return template_params;
|
||||
}
|
||||
}
|
||||
|
||||
return smallvec![];
|
||||
|
|
|
@ -363,7 +363,6 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
|
|||
|
||||
state_specific_fields.into_iter().chain(common_fields).collect()
|
||||
},
|
||||
// FIXME: this is a no-op. `build_generic_type_param_di_nodes` only works for Adts.
|
||||
|cx| build_generic_type_param_di_nodes(cx, coroutine_type_and_layout.ty),
|
||||
)
|
||||
.di_node
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use std::cell::{OnceCell, RefCell};
|
||||
use std::ops::Range;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use std::{iter, ptr};
|
||||
|
||||
use libc::c_uint;
|
||||
use metadata::create_subroutine_type;
|
||||
|
@ -486,10 +486,40 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
generics: &ty::Generics,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
) -> &'ll DIArray {
|
||||
let template_params = metadata::get_template_parameters(cx, generics, args);
|
||||
if args.types().next().is_none() {
|
||||
return create_DIArray(DIB(cx), &[]);
|
||||
}
|
||||
|
||||
// Again, only create type information if full debuginfo is enabled
|
||||
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
|
||||
let names = get_parameter_names(cx, generics);
|
||||
iter::zip(args, names)
|
||||
.filter_map(|(kind, name)| {
|
||||
kind.as_type().map(|ty| {
|
||||
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
|
||||
let actual_type_metadata = type_di_node(cx, actual_type);
|
||||
Some(cx.create_template_type_parameter(
|
||||
name.as_str(),
|
||||
actual_type_metadata,
|
||||
))
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
create_DIArray(DIB(cx), &template_params)
|
||||
}
|
||||
|
||||
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
|
||||
let mut names = generics.parent.map_or_else(Vec::new, |def_id| {
|
||||
get_parameter_names(cx, cx.tcx.generics_of(def_id))
|
||||
});
|
||||
names.extend(generics.own_params.iter().map(|param| param.name));
|
||||
names
|
||||
}
|
||||
|
||||
/// Returns a scope, plus `true` if that's a type scope for "class" methods,
|
||||
/// otherwise `false` for plain namespace scopes.
|
||||
fn get_containing_scope<'ll, 'tcx>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue