use cleanup::{self, CleanupMethods, DropHint};
use closure;
use common::{Block, C_bool, C_bytes_in_context, C_i32, C_int, C_uint, C_integral};
-use collector::{self, TransItemState, TransItemCollectionMode};
+use collector::{self, TransItemCollectionMode};
use common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef};
use common::{CrateContext, DropFlagHintsMap, Field, FunctionContext};
use common::{Result, NodeIdAndSpan, VariantInfo};
closure_env: closure::ClosureEnv) {
ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1);
- if collector::collecting_debug_information(ccx.shared()) {
- ccx.record_translation_item_as_generated(TransItem::Fn(instance));
- }
-
let _icx = push_ctxt("trans_closure");
if !ccx.sess().no_landing_pads() {
attributes::emit_uwtable(llfndecl, true);
}
}
- collector::print_collection_results(&shared_ccx);
symbol_names_test::report_symbol_names(&shared_ccx);
{
let mut ccx_map = scx.translation_items().borrow_mut();
for trans_item in items.iter().cloned() {
- ccx_map.insert(trans_item, TransItemState::PredictedButNotGenerated);
+ ccx_map.insert(trans_item);
}
}
visitor.visit_mir(promoted);
}
}
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
-pub enum TransItemState {
- PredictedAndGenerated,
- PredictedButNotGenerated,
- NotPredictedButGenerated,
-}
-
-pub fn collecting_debug_information(scx: &SharedCrateContext) -> bool {
- return cfg!(debug_assertions) &&
- scx.sess().opts.debugging_opts.print_trans_items.is_some();
-}
-
-pub fn print_collection_results<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>) {
- use std::hash::{Hash, SipHasher, Hasher};
-
- if !collecting_debug_information(scx) {
- return;
- }
-
- fn hash<T: Hash>(t: &T) -> u64 {
- let mut s = SipHasher::new();
- t.hash(&mut s);
- s.finish()
- }
-
- let trans_items = scx.translation_items().borrow();
-
- {
- // Check for duplicate item keys
- let mut item_keys = FnvHashMap();
-
- for (item, item_state) in trans_items.iter() {
- let k = item.to_string(scx.tcx());
-
- if item_keys.contains_key(&k) {
- let prev: (TransItem, TransItemState) = item_keys[&k];
- debug!("DUPLICATE KEY: {}", k);
- debug!(" (1) {:?}, {:?}, hash: {}, raw: {}",
- prev.0,
- prev.1,
- hash(&prev.0),
- prev.0.to_raw_string());
-
- debug!(" (2) {:?}, {:?}, hash: {}, raw: {}",
- *item,
- *item_state,
- hash(item),
- item.to_raw_string());
- } else {
- item_keys.insert(k, (*item, *item_state));
- }
- }
- }
-
- let mut predicted_but_not_generated = FnvHashSet();
- let mut not_predicted_but_generated = FnvHashSet();
- let mut predicted = FnvHashSet();
- let mut generated = FnvHashSet();
-
- for (item, item_state) in trans_items.iter() {
- let item_key = item.to_string(scx.tcx());
-
- match *item_state {
- TransItemState::PredictedAndGenerated => {
- predicted.insert(item_key.clone());
- generated.insert(item_key);
- }
- TransItemState::PredictedButNotGenerated => {
- predicted_but_not_generated.insert(item_key.clone());
- predicted.insert(item_key);
- }
- TransItemState::NotPredictedButGenerated => {
- not_predicted_but_generated.insert(item_key.clone());
- generated.insert(item_key);
- }
- }
- }
-
- debug!("Total number of translation items predicted: {}", predicted.len());
- debug!("Total number of translation items generated: {}", generated.len());
- debug!("Total number of translation items predicted but not generated: {}",
- predicted_but_not_generated.len());
- debug!("Total number of translation items not predicted but generated: {}",
- not_predicted_but_generated.len());
-
- if generated.len() > 0 {
- debug!("Failed to predict {}% of translation items",
- (100 * not_predicted_but_generated.len()) / generated.len());
- }
- if generated.len() > 0 {
- debug!("Predict {}% too many translation items",
- (100 * predicted_but_not_generated.len()) / generated.len());
- }
-
- debug!("");
- debug!("Not predicted but generated:");
- debug!("============================");
- for item in not_predicted_but_generated {
- debug!(" - {}", item);
- }
-
- debug!("");
- debug!("Predicted but not generated:");
- debug!("============================");
- for item in predicted_but_not_generated {
- debug!(" - {}", item);
- }
-}
use {abi, adt, closure, debuginfo, expr, machine};
use base::{self, push_ctxt};
use callee::Callee;
-use collector;
use trans_item::TransItem;
use common::{type_is_sized, C_nil, const_get_elt};
use common::{CrateContext, C_integral, C_floating, C_bool, C_str_slice, C_bytes, val_ty};
id: ast::NodeId,
attrs: &[ast::Attribute])
-> Result<ValueRef, ConstEvalErr> {
-
- if collector::collecting_debug_information(ccx.shared()) {
- ccx.record_translation_item_as_generated(TransItem::Static(id));
- }
-
unsafe {
let _icx = push_ctxt("trans_static");
let def_id = ccx.tcx().map.local_def_id(id);
use monomorphize::Instance;
use partitioning::CodegenUnit;
-use collector::TransItemState;
use trans_item::TransItem;
use type_::{Type, TypeNames};
use rustc::ty::subst::{Substs, VecPerParamSpace};
use session::Session;
use symbol_map::SymbolMap;
use util::sha2::Sha256;
-use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap};
+use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap, FnvHashSet};
use std::ffi::{CStr, CString};
use std::cell::{Cell, RefCell};
use_dll_storage_attrs: bool,
- translation_items: RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>>,
+ translation_items: RefCell<FnvHashSet<TransItem<'tcx>>>,
trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
}
check_overflow: check_overflow,
check_drop_flag_for_sanity: check_drop_flag_for_sanity,
use_dll_storage_attrs: use_dll_storage_attrs,
- translation_items: RefCell::new(FnvHashMap()),
+ translation_items: RefCell::new(FnvHashSet()),
trait_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
}
}
}
}
- pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {
+ pub fn translation_items(&self) -> &RefCell<FnvHashSet<TransItem<'tcx>>> {
&self.translation_items
}
&*self.local().symbol_map
}
- pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {
+ pub fn translation_items(&self) -> &RefCell<FnvHashSet<TransItem<'tcx>>> {
&self.shared.translation_items
}
- pub fn record_translation_item_as_generated(&self, cgi: TransItem<'tcx>) {
- if self.sess().opts.debugging_opts.print_trans_items.is_none() {
- return;
- }
-
- let mut codegen_items = self.translation_items().borrow_mut();
-
- if codegen_items.contains_key(&cgi) {
- codegen_items.insert(cgi, TransItemState::PredictedAndGenerated);
- } else {
- codegen_items.insert(cgi, TransItemState::NotPredictedButGenerated);
- }
- }
-
/// Given the def-id of some item that has no type parameters, make
/// a suitable "empty substs" for it.
pub fn empty_substs_for_def_id(&self, item_def_id: DefId) -> &'tcx Substs<'tcx> {
use callee::{Callee, ArgVals};
use cleanup;
use cleanup::CleanupMethods;
-use collector;
use common::*;
use debuginfo::DebugLoc;
use expr;
fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueKind<'tcx>)
-> Block<'blk, 'tcx> {
- if collector::collecting_debug_information(bcx.ccx().shared()) {
- bcx.ccx()
- .record_translation_item_as_generated(TransItem::DropGlue(g));
- }
-
let t = g.ty();
let skip_dtor = match g { DropGlueKind::Ty(_) => false, DropGlueKind::TyContents(_) => true };
}) => {
let trans_item = TransItem::Fn(instance);
- if ccx.shared().translation_items().borrow().contains_key(&trans_item) {
+ if ccx.shared().translation_items().borrow().contains(&trans_item) {
attributes::from_fn_attrs(ccx, attrs, lldecl);
llvm::SetLinkage(lldecl, llvm::ExternalLinkage);
} else {