Add MonoItemData::inlined
.
This commit is contained in:
parent
299179e694
commit
77b053a2dd
2 changed files with 19 additions and 17 deletions
|
@ -248,8 +248,14 @@ pub struct CodegenUnit<'tcx> {
|
||||||
/// Auxiliary info about a `MonoItem`.
|
/// Auxiliary info about a `MonoItem`.
|
||||||
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
|
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
|
||||||
pub struct MonoItemData {
|
pub struct MonoItemData {
|
||||||
|
/// A cached copy of the result of `MonoItem::instantiation_mode`, where
|
||||||
|
/// `GloballyShared` maps to `false` and `LocalCopy` maps to `true`.
|
||||||
|
pub inlined: bool,
|
||||||
|
|
||||||
pub linkage: Linkage,
|
pub linkage: Linkage,
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
|
|
||||||
|
/// A cached copy of the result of `MonoItem::size_estimate`.
|
||||||
pub size_estimate: usize,
|
pub size_estimate: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,8 @@ where
|
||||||
}
|
}
|
||||||
let size_estimate = mono_item.size_estimate(cx.tcx);
|
let size_estimate = mono_item.size_estimate(cx.tcx);
|
||||||
|
|
||||||
cgu.items_mut().insert(mono_item, MonoItemData { linkage, visibility, size_estimate });
|
cgu.items_mut()
|
||||||
|
.insert(mono_item, MonoItemData { inlined: false, linkage, visibility, size_estimate });
|
||||||
|
|
||||||
// Get all inlined items that are reachable from `mono_item` without
|
// Get all inlined items that are reachable from `mono_item` without
|
||||||
// going via another root item. This includes drop-glue, functions from
|
// going via another root item. This includes drop-glue, functions from
|
||||||
|
@ -263,6 +264,7 @@ where
|
||||||
for inlined_item in reachable_inlined_items {
|
for inlined_item in reachable_inlined_items {
|
||||||
// This is a CGU-private copy.
|
// This is a CGU-private copy.
|
||||||
cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData {
|
cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData {
|
||||||
|
inlined: true,
|
||||||
linkage: Linkage::Internal,
|
linkage: Linkage::Internal,
|
||||||
visibility: Visibility::Default,
|
visibility: Visibility::Default,
|
||||||
size_estimate: inlined_item.size_estimate(cx.tcx),
|
size_estimate: inlined_item.size_estimate(cx.tcx),
|
||||||
|
@ -870,19 +872,16 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
|
||||||
all_cgu_sizes.push(cgu.size_estimate());
|
all_cgu_sizes.push(cgu.size_estimate());
|
||||||
|
|
||||||
for (item, data) in cgu.items() {
|
for (item, data) in cgu.items() {
|
||||||
match item.instantiation_mode(tcx) {
|
if !data.inlined {
|
||||||
InstantiationMode::GloballyShared { .. } => {
|
root_items += 1;
|
||||||
root_items += 1;
|
root_size += data.size_estimate;
|
||||||
root_size += data.size_estimate;
|
} else {
|
||||||
}
|
if inlined_items.insert(item) {
|
||||||
InstantiationMode::LocalCopy => {
|
unique_inlined_items += 1;
|
||||||
if inlined_items.insert(item) {
|
unique_inlined_size += data.size_estimate;
|
||||||
unique_inlined_items += 1;
|
|
||||||
unique_inlined_size += data.size_estimate;
|
|
||||||
}
|
|
||||||
placed_inlined_items += 1;
|
|
||||||
placed_inlined_size += data.size_estimate;
|
|
||||||
}
|
}
|
||||||
|
placed_inlined_items += 1;
|
||||||
|
placed_inlined_size += data.size_estimate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,10 +936,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
|
||||||
let symbol_name = item.symbol_name(tcx).name;
|
let symbol_name = item.symbol_name(tcx).name;
|
||||||
let symbol_hash_start = symbol_name.rfind('h');
|
let symbol_hash_start = symbol_name.rfind('h');
|
||||||
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
|
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
|
||||||
let kind = match item.instantiation_mode(tcx) {
|
let kind = if !data.inlined { "root" } else { "inlined" };
|
||||||
InstantiationMode::GloballyShared { .. } => "root",
|
|
||||||
InstantiationMode::LocalCopy => "inlined",
|
|
||||||
};
|
|
||||||
let size = data.size_estimate;
|
let size = data.size_estimate;
|
||||||
let _ = with_no_trimmed_paths!(writeln!(
|
let _ = with_no_trimmed_paths!(writeln!(
|
||||||
s,
|
s,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue