Skip to content
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

Linker regression #36960

Merged
merged 3 commits into from
Oct 6, 2016
Merged
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
8 changes: 7 additions & 1 deletion src/librustc_trans/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
llreffn: ValueRef)
-> ValueRef
{
if let Some(&llfn) = ccx.instances().borrow().get(&method_instance) {
return llfn;
}

debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={:?})",
closure_def_id, substs, Value(llreffn));

Expand Down Expand Up @@ -257,7 +261,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(

// Create the by-value helper.
let function_name = method_instance.symbol_name(ccx.shared());
let lloncefn = declare::declare_fn(ccx, &function_name, llonce_fn_ty);
let lloncefn = declare::define_internal_fn(ccx, &function_name, llonce_fn_ty);
attributes::set_frame_pointer_elimination(ccx, lloncefn);

let (block_arena, fcx): (TypedArena<_>, FunctionContext);
Expand Down Expand Up @@ -312,5 +316,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(

fcx.finish(bcx, DebugLoc::None);

ccx.instances().borrow_mut().insert(method_instance, lloncefn);

lloncefn
}
21 changes: 16 additions & 5 deletions src/librustc_trans/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
let mut initial_partitioning = place_root_translation_items(scx,
trans_items);

debug_dump(tcx, "INITIAL PARTITONING:", initial_partitioning.codegen_units.iter());
debug_dump(scx, "INITIAL PARTITONING:", initial_partitioning.codegen_units.iter());

// If the partitioning should produce a fixed count of codegen units, merge
// until that count is reached.
if let PartitioningStrategy::FixedUnitCount(count) = strategy {
merge_codegen_units(&mut initial_partitioning, count, &tcx.crate_name[..]);

debug_dump(tcx, "POST MERGING:", initial_partitioning.codegen_units.iter());
debug_dump(scx, "POST MERGING:", initial_partitioning.codegen_units.iter());
}

// In the next step, we use the inlining map to determine which addtional
Expand All @@ -283,7 +283,7 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
let post_inlining = place_inlined_translation_items(initial_partitioning,
inlining_map);

debug_dump(tcx, "POST INLINING:", post_inlining.0.iter());
debug_dump(scx, "POST INLINING:", post_inlining.0.iter());

// Finally, sort by codegen unit name, so that we get deterministic results
let mut result = post_inlining.0;
Expand Down Expand Up @@ -551,7 +551,7 @@ fn numbered_codegen_unit_name(crate_name: &str, index: usize) -> InternedString
index)[..])
}

fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn debug_dump<'a, 'b, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
label: &str,
cgus: I)
where I: Iterator<Item=&'b CodegenUnit<'tcx>>,
Expand All @@ -560,10 +560,21 @@ fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if cfg!(debug_assertions) {
debug!("{}", label);
for cgu in cgus {
let symbol_map = SymbolMap::build(scx, cgu.items
.iter()
.map(|(&trans_item, _)| trans_item));
debug!("CodegenUnit {}:", cgu.name);

for (trans_item, linkage) in &cgu.items {
debug!(" - {} [{:?}]", trans_item.to_string(tcx), linkage);
let symbol_name = symbol_map.get_or_compute(scx, *trans_item);
let symbol_hash_start = symbol_name.rfind('h');
let symbol_hash = symbol_hash_start.map(|i| &symbol_name[i ..])
.unwrap_or("<no hash>");

debug!(" - {} [{:?}] [{}]",
trans_item.to_string(scx.tcx()),
linkage,
symbol_hash);
}

debug!("");
Expand Down