.iter()
.cloned()
.filter(|trans_item|{
- let def_id = match *trans_item {
- TransItem::DropGlue(..) => {
- return false
- },
- TransItem::Fn(ref instance) => {
- instance.def
- }
- TransItem::Static(node_id) => {
- tcx.map.local_def_id(node_id)
- }
- };
-
- trans_item.explicit_linkage(tcx).is_some() ||
- attr::contains_extern_indicator(tcx.sess.diagnostic(),
- &tcx.get_attrs(def_id))
+ trans_item.explicit_linkage(tcx).is_some()
})
.map(|trans_item| symbol_map.get_or_compute(scx, trans_item))
.collect();
partitioning::partition(scx,
items.iter().cloned(),
strategy,
- &inlining_map,
- scx.reachable())
+ &inlining_map)
});
assert!(scx.tcx().sess.opts.cg.codegen_units == codegen_units.len() ||
use syntax::ast::NodeId;
use syntax::parse::token::{self, InternedString};
use trans_item::TransItem;
-use util::nodemap::{FnvHashMap, FnvHashSet, NodeSet};
+use util::nodemap::{FnvHashMap, FnvHashSet};
pub enum PartitioningStrategy {
/// Generate one codegen unit per source-level module.
pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
trans_items: I,
strategy: PartitioningStrategy,
- inlining_map: &InliningMap<'tcx>,
- reachable: &NodeSet)
+ inlining_map: &InliningMap<'tcx>)
-> Vec<CodegenUnit<'tcx>>
where I: Iterator<Item = TransItem<'tcx>>
{
// respective 'home' codegen unit. Regular translation items are all
// functions and statics defined in the local crate.
let mut initial_partitioning = place_root_translation_items(scx,
- trans_items,
- reachable);
+ trans_items);
debug_dump(tcx, "INITIAL PARTITONING:", initial_partitioning.codegen_units.iter());
struct PostInliningPartitioning<'tcx>(Vec<CodegenUnit<'tcx>>);
fn place_root_translation_items<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
- trans_items: I,
- _reachable: &NodeSet)
+ trans_items: I)
-> PreInliningPartitioning<'tcx>
where I: Iterator<Item = TransItem<'tcx>>
{
// This is a non-generic functions, we always
// make it visible externally on the chance that
// it might be used in another codegen unit.
+ // Later on base::internalize_symbols() will
+ // assign "internal" linkage to those symbols
+ // that are not referenced from other codegen
+ // units (and are not publicly visible).
llvm::ExternalLinkage
} else {
// In the current setup, generic functions cannot
/// True if the translation item should only be translated to LLVM IR if
/// it is referenced somewhere (like inline functions, for example).
- pub fn is_instantiated_only_on_demand(&self, tcx: TyCtxt) -> bool {
+ pub fn is_instantiated_only_on_demand(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
+ if self.explicit_linkage(tcx).is_some() {
+ return false;
+ }
+
match *self {
TransItem::Fn(ref instance) => {
!instance.def.is_local() ||