Skip to content

Commit 56a3bf2

Browse files
trans: Remove tracking of translation item state.
The data tracked here was meant to compare the output of the translation item collector to the set of translation items found by the on-demand translator.
1 parent 4cdf365 commit 56a3bf2

File tree

6 files changed

+8
-149
lines changed

6 files changed

+8
-149
lines changed

src/librustc_trans/base.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use callee::{Callee, CallArgs, ArgExprs, ArgVals};
5858
use cleanup::{self, CleanupMethods, DropHint};
5959
use closure;
6060
use common::{Block, C_bool, C_bytes_in_context, C_i32, C_int, C_uint, C_integral};
61-
use collector::{self, TransItemState, TransItemCollectionMode};
61+
use collector::{self, TransItemCollectionMode};
6262
use common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef};
6363
use common::{CrateContext, DropFlagHintsMap, Field, FunctionContext};
6464
use common::{Result, NodeIdAndSpan, VariantInfo};
@@ -1835,10 +1835,6 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18351835
closure_env: closure::ClosureEnv) {
18361836
ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1);
18371837

1838-
if collector::collecting_debug_information(ccx.shared()) {
1839-
ccx.record_translation_item_as_generated(TransItem::Fn(instance));
1840-
}
1841-
18421838
let _icx = push_ctxt("trans_closure");
18431839
if !ccx.sess().no_landing_pads() {
18441840
attributes::emit_uwtable(llfndecl, true);
@@ -2662,7 +2658,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
26622658
}
26632659
}
26642660

2665-
collector::print_collection_results(&shared_ccx);
26662661
symbol_names_test::report_symbol_names(&shared_ccx);
26672662

26682663
{
@@ -2882,7 +2877,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
28822877
let mut ccx_map = scx.translation_items().borrow_mut();
28832878

28842879
for trans_item in items.iter().cloned() {
2885-
ccx_map.insert(trans_item, TransItemState::PredictedButNotGenerated);
2880+
ccx_map.insert(trans_item);
28862881
}
28872882
}
28882883

src/librustc_trans/collector.rs

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,112 +1271,3 @@ fn visit_mir_and_promoted<'tcx, V: MirVisitor<'tcx>>(mut visitor: V, mir: &mir::
12711271
visitor.visit_mir(promoted);
12721272
}
12731273
}
1274-
1275-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1276-
pub enum TransItemState {
1277-
PredictedAndGenerated,
1278-
PredictedButNotGenerated,
1279-
NotPredictedButGenerated,
1280-
}
1281-
1282-
pub fn collecting_debug_information(scx: &SharedCrateContext) -> bool {
1283-
return cfg!(debug_assertions) &&
1284-
scx.sess().opts.debugging_opts.print_trans_items.is_some();
1285-
}
1286-
1287-
pub fn print_collection_results<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>) {
1288-
use std::hash::{Hash, SipHasher, Hasher};
1289-
1290-
if !collecting_debug_information(scx) {
1291-
return;
1292-
}
1293-
1294-
fn hash<T: Hash>(t: &T) -> u64 {
1295-
let mut s = SipHasher::new();
1296-
t.hash(&mut s);
1297-
s.finish()
1298-
}
1299-
1300-
let trans_items = scx.translation_items().borrow();
1301-
1302-
{
1303-
// Check for duplicate item keys
1304-
let mut item_keys = FnvHashMap();
1305-
1306-
for (item, item_state) in trans_items.iter() {
1307-
let k = item.to_string(scx.tcx());
1308-
1309-
if item_keys.contains_key(&k) {
1310-
let prev: (TransItem, TransItemState) = item_keys[&k];
1311-
debug!("DUPLICATE KEY: {}", k);
1312-
debug!(" (1) {:?}, {:?}, hash: {}, raw: {}",
1313-
prev.0,
1314-
prev.1,
1315-
hash(&prev.0),
1316-
prev.0.to_raw_string());
1317-
1318-
debug!(" (2) {:?}, {:?}, hash: {}, raw: {}",
1319-
*item,
1320-
*item_state,
1321-
hash(item),
1322-
item.to_raw_string());
1323-
} else {
1324-
item_keys.insert(k, (*item, *item_state));
1325-
}
1326-
}
1327-
}
1328-
1329-
let mut predicted_but_not_generated = FnvHashSet();
1330-
let mut not_predicted_but_generated = FnvHashSet();
1331-
let mut predicted = FnvHashSet();
1332-
let mut generated = FnvHashSet();
1333-
1334-
for (item, item_state) in trans_items.iter() {
1335-
let item_key = item.to_string(scx.tcx());
1336-
1337-
match *item_state {
1338-
TransItemState::PredictedAndGenerated => {
1339-
predicted.insert(item_key.clone());
1340-
generated.insert(item_key);
1341-
}
1342-
TransItemState::PredictedButNotGenerated => {
1343-
predicted_but_not_generated.insert(item_key.clone());
1344-
predicted.insert(item_key);
1345-
}
1346-
TransItemState::NotPredictedButGenerated => {
1347-
not_predicted_but_generated.insert(item_key.clone());
1348-
generated.insert(item_key);
1349-
}
1350-
}
1351-
}
1352-
1353-
debug!("Total number of translation items predicted: {}", predicted.len());
1354-
debug!("Total number of translation items generated: {}", generated.len());
1355-
debug!("Total number of translation items predicted but not generated: {}",
1356-
predicted_but_not_generated.len());
1357-
debug!("Total number of translation items not predicted but generated: {}",
1358-
not_predicted_but_generated.len());
1359-
1360-
if generated.len() > 0 {
1361-
debug!("Failed to predict {}% of translation items",
1362-
(100 * not_predicted_but_generated.len()) / generated.len());
1363-
}
1364-
if generated.len() > 0 {
1365-
debug!("Predict {}% too many translation items",
1366-
(100 * predicted_but_not_generated.len()) / generated.len());
1367-
}
1368-
1369-
debug!("");
1370-
debug!("Not predicted but generated:");
1371-
debug!("============================");
1372-
for item in not_predicted_but_generated {
1373-
debug!(" - {}", item);
1374-
}
1375-
1376-
debug!("");
1377-
debug!("Predicted but not generated:");
1378-
debug!("============================");
1379-
for item in predicted_but_not_generated {
1380-
debug!(" - {}", item);
1381-
}
1382-
}

src/librustc_trans/consts.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use rustc::hir::map as hir_map;
2121
use {abi, adt, closure, debuginfo, expr, machine};
2222
use base::{self, push_ctxt};
2323
use callee::Callee;
24-
use collector;
2524
use trans_item::TransItem;
2625
use common::{type_is_sized, C_nil, const_get_elt};
2726
use common::{CrateContext, C_integral, C_floating, C_bool, C_str_slice, C_bytes, val_ty};
@@ -1143,11 +1142,6 @@ pub fn trans_static(ccx: &CrateContext,
11431142
id: ast::NodeId,
11441143
attrs: &[ast::Attribute])
11451144
-> Result<ValueRef, ConstEvalErr> {
1146-
1147-
if collector::collecting_debug_information(ccx.shared()) {
1148-
ccx.record_translation_item_as_generated(TransItem::Static(id));
1149-
}
1150-
11511145
unsafe {
11521146
let _icx = push_ctxt("trans_static");
11531147
let def_id = ccx.tcx().map.local_def_id(id);

src/librustc_trans/context.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use mir::CachedMir;
2828
use monomorphize::Instance;
2929

3030
use partitioning::CodegenUnit;
31-
use collector::TransItemState;
3231
use trans_item::TransItem;
3332
use type_::{Type, TypeNames};
3433
use rustc::ty::subst::{Substs, VecPerParamSpace};
@@ -37,7 +36,7 @@ use session::config::NoDebugInfo;
3736
use session::Session;
3837
use symbol_map::SymbolMap;
3938
use util::sha2::Sha256;
40-
use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap};
39+
use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap, FnvHashSet};
4140

4241
use std::ffi::{CStr, CString};
4342
use std::cell::{Cell, RefCell};
@@ -85,7 +84,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
8584

8685
use_dll_storage_attrs: bool,
8786

88-
translation_items: RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>>,
87+
translation_items: RefCell<FnvHashSet<TransItem<'tcx>>>,
8988
trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
9089
}
9190

@@ -419,7 +418,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
419418
check_overflow: check_overflow,
420419
check_drop_flag_for_sanity: check_drop_flag_for_sanity,
421420
use_dll_storage_attrs: use_dll_storage_attrs,
422-
translation_items: RefCell::new(FnvHashMap()),
421+
translation_items: RefCell::new(FnvHashSet()),
423422
trait_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
424423
}
425424
}
@@ -482,7 +481,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
482481
}
483482
}
484483

485-
pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {
484+
pub fn translation_items(&self) -> &RefCell<FnvHashSet<TransItem<'tcx>>> {
486485
&self.translation_items
487486
}
488487

@@ -902,24 +901,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
902901
&*self.local().symbol_map
903902
}
904903

905-
pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {
904+
pub fn translation_items(&self) -> &RefCell<FnvHashSet<TransItem<'tcx>>> {
906905
&self.shared.translation_items
907906
}
908907

909-
pub fn record_translation_item_as_generated(&self, cgi: TransItem<'tcx>) {
910-
if self.sess().opts.debugging_opts.print_trans_items.is_none() {
911-
return;
912-
}
913-
914-
let mut codegen_items = self.translation_items().borrow_mut();
915-
916-
if codegen_items.contains_key(&cgi) {
917-
codegen_items.insert(cgi, TransItemState::PredictedAndGenerated);
918-
} else {
919-
codegen_items.insert(cgi, TransItemState::NotPredictedButGenerated);
920-
}
921-
}
922-
923908
/// Given the def-id of some item that has no type parameters, make
924909
/// a suitable "empty substs" for it.
925910
pub fn empty_substs_for_def_id(&self, item_def_id: DefId) -> &'tcx Substs<'tcx> {

src/librustc_trans/glue.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use build::*;
2727
use callee::{Callee, ArgVals};
2828
use cleanup;
2929
use cleanup::CleanupMethods;
30-
use collector;
3130
use common::*;
3231
use debuginfo::DebugLoc;
3332
use expr;
@@ -482,11 +481,6 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
482481

483482
fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueKind<'tcx>)
484483
-> Block<'blk, 'tcx> {
485-
if collector::collecting_debug_information(bcx.ccx().shared()) {
486-
bcx.ccx()
487-
.record_translation_item_as_generated(TransItem::DropGlue(g));
488-
}
489-
490484
let t = g.ty();
491485

492486
let skip_dtor = match g { DropGlueKind::Ty(_) => false, DropGlueKind::TyContents(_) => true };

src/librustc_trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
123123
}) => {
124124
let trans_item = TransItem::Fn(instance);
125125

126-
if ccx.shared().translation_items().borrow().contains_key(&trans_item) {
126+
if ccx.shared().translation_items().borrow().contains(&trans_item) {
127127
attributes::from_fn_attrs(ccx, attrs, lldecl);
128128
llvm::SetLinkage(lldecl, llvm::ExternalLinkage);
129129
} else {

0 commit comments

Comments
 (0)