Skip to content

Commit 06c094d

Browse files
committed
---
yaml --- r: 146687 b: refs/heads/try2 c: ec27c09 h: refs/heads/master i: 146685: 0de880f 146683: a15b172 146679: 1746a6b 146671: 5998319 146655: 8315cdc 146623: e07f3e8 146559: 2ed74a1 146431: 6c432b2 v: v3
1 parent 41b53ed commit 06c094d

File tree

5 files changed

+146
-285
lines changed

5 files changed

+146
-285
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6c8b702cf7f7b67e3076091cdf12750551f3830c
8+
refs/heads/try2: ec27c09bdfa9fbdbf643b3f2f29146c1747e7297
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/reachable.rs

Lines changed: 77 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -260,132 +260,103 @@ impl ReachableContext {
260260
continue
261261
}
262262
scanned.insert(search_item);
263-
match self.tcx.items.find(&search_item) {
264-
Some(item) => self.propagate_node(item, search_item,
265-
&mut visitor),
266-
None if search_item == ast::CRATE_NODE_ID => {}
267-
None => {
268-
self.tcx.sess.bug(format!("found unmapped ID in worklist: \
269-
{}",
270-
search_item))
271-
}
272-
}
273-
}
274-
}
263+
self.reachable_symbols.insert(search_item);
275264

276-
fn propagate_node(&self, node: &ast_map::ast_node,
277-
search_item: ast::NodeId,
278-
visitor: &mut MarkSymbolVisitor) {
279-
if !*self.tcx.sess.building_library {
280-
// If we are building an executable, then there's no need to flag
281-
// anything as external except for `extern fn` types. These
282-
// functions may still participate in some form of native interface,
283-
// but all other rust-only interfaces can be private (they will not
284-
// participate in linkage after this product is produced)
285-
match *node {
286-
ast_map::node_item(item, _) => {
265+
// Find the AST block corresponding to the item and visit it,
266+
// marking all path expressions that resolve to something
267+
// interesting.
268+
match self.tcx.items.find(&search_item) {
269+
Some(&ast_map::node_item(item, _)) => {
287270
match item.node {
288-
ast::item_fn(_, ast::extern_fn, _, _, _) => {
289-
self.reachable_symbols.insert(search_item);
271+
ast::item_fn(_, _, _, _, ref search_block) => {
272+
if item_might_be_inlined(item) {
273+
visit::walk_block(&mut visitor, search_block, ())
274+
}
290275
}
291-
_ => {}
292-
}
293-
}
294-
_ => {}
295-
}
296-
} else {
297-
// If we are building a library, then reachable symbols will
298-
// continue to participate in linkage after this product is
299-
// produced. In this case, we traverse the ast node, recursing on
300-
// all reachable nodes from this one.
301-
self.reachable_symbols.insert(search_item);
302-
}
303276

304-
match *node {
305-
ast_map::node_item(item, _) => {
306-
match item.node {
307-
ast::item_fn(_, _, _, _, ref search_block) => {
308-
if item_might_be_inlined(item) {
309-
visit::walk_block(visitor, search_block, ())
310-
}
311-
}
312-
313-
// Implementations of exported structs/enums need to get
314-
// added to the worklist (as all their methods should be
315-
// accessible)
316-
ast::item_struct(*) | ast::item_enum(*) => {
317-
let def = local_def(item.id);
318-
let impls = match self.tcx.inherent_impls.find(&def) {
319-
Some(&impls) => impls,
320-
None => return
321-
};
322-
for imp in impls.iter() {
323-
if is_local(imp.did) {
324-
self.worklist.push(imp.did.node);
277+
// Implementations of exported structs/enums need to get
278+
// added to the worklist (as all their methods should be
279+
// accessible)
280+
ast::item_struct(*) | ast::item_enum(*) => {
281+
let def = local_def(item.id);
282+
let impls = match self.tcx.inherent_impls.find(&def) {
283+
Some(&impls) => impls,
284+
None => continue
285+
};
286+
for imp in impls.iter() {
287+
if is_local(imp.did) {
288+
self.worklist.push(imp.did.node);
289+
}
325290
}
326291
}
327-
}
328292

329-
// Propagate through this impl
330-
ast::item_impl(_, _, _, ref methods) => {
331-
for method in methods.iter() {
332-
self.worklist.push(method.id);
293+
// Propagate through this impl
294+
ast::item_impl(_, _, _, ref methods) => {
295+
for method in methods.iter() {
296+
self.worklist.push(method.id);
297+
}
333298
}
334-
}
335299

336-
// Default methods of exported traits need to all be
337-
// accessible.
338-
ast::item_trait(_, _, ref methods) => {
339-
for method in methods.iter() {
340-
match *method {
341-
ast::required(*) => {}
342-
ast::provided(ref method) => {
343-
self.worklist.push(method.id);
300+
// Default methods of exported traits need to all be
301+
// accessible.
302+
ast::item_trait(_, _, ref methods) => {
303+
for method in methods.iter() {
304+
match *method {
305+
ast::required(*) => {}
306+
ast::provided(ref method) => {
307+
self.worklist.push(method.id);
308+
}
344309
}
345310
}
346311
}
347-
}
348312

349-
// These are normal, nothing reachable about these
350-
// inherently and their children are already in the
351-
// worklist
352-
ast::item_static(*) | ast::item_ty(*) |
353-
ast::item_mod(*) | ast::item_foreign_mod(*) => {}
313+
// These are normal, nothing reachable about these
314+
// inherently and their children are already in the
315+
// worklist
316+
ast::item_static(*) | ast::item_ty(*) |
317+
ast::item_mod(*) | ast::item_foreign_mod(*) => {}
354318

355-
_ => {
356-
self.tcx.sess.span_bug(item.span,
357-
"found non-function item \
358-
in worklist?!")
319+
_ => {
320+
self.tcx.sess.span_bug(item.span,
321+
"found non-function item \
322+
in worklist?!")
323+
}
359324
}
360325
}
361-
}
362-
ast_map::node_trait_method(trait_method, _, _) => {
363-
match *trait_method {
364-
ast::required(*) => {
365-
// Keep going, nothing to get exported
326+
Some(&ast_map::node_trait_method(trait_method, _, _)) => {
327+
match *trait_method {
328+
ast::required(*) => {
329+
// Keep going, nothing to get exported
330+
}
331+
ast::provided(ref method) => {
332+
visit::walk_block(&mut visitor, &method.body, ())
333+
}
366334
}
367-
ast::provided(ref method) => {
368-
visit::walk_block(visitor, &method.body, ())
335+
}
336+
Some(&ast_map::node_method(method, did, _)) => {
337+
if method_might_be_inlined(self.tcx, method, did) {
338+
visit::walk_block(&mut visitor, &method.body, ())
369339
}
370340
}
371-
}
372-
ast_map::node_method(method, did, _) => {
373-
if method_might_be_inlined(self.tcx, method, did) {
374-
visit::walk_block(visitor, &method.body, ())
341+
// Nothing to recurse on for these
342+
Some(&ast_map::node_foreign_item(*)) |
343+
Some(&ast_map::node_variant(*)) |
344+
Some(&ast_map::node_struct_ctor(*)) => {}
345+
Some(_) => {
346+
let ident_interner = token::get_ident_interner();
347+
let desc = ast_map::node_id_to_str(self.tcx.items,
348+
search_item,
349+
ident_interner);
350+
self.tcx.sess.bug(format!("found unexpected thingy in \
351+
worklist: {}",
352+
desc))
353+
}
354+
None if search_item == ast::CRATE_NODE_ID => {}
355+
None => {
356+
self.tcx.sess.bug(format!("found unmapped ID in worklist: \
357+
{}",
358+
search_item))
375359
}
376-
}
377-
// Nothing to recurse on for these
378-
ast_map::node_foreign_item(*) |
379-
ast_map::node_variant(*) |
380-
ast_map::node_struct_ctor(*) => {}
381-
_ => {
382-
let ident_interner = token::get_ident_interner();
383-
let desc = ast_map::node_id_to_str(self.tcx.items,
384-
search_item,
385-
ident_interner);
386-
self.tcx.sess.bug(format!("found unexpected thingy in \
387-
worklist: {}",
388-
desc))
389360
}
390361
}
391362
}

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,7 @@ fn finish_register_fn(ccx: @mut CrateContext, sp: Span, sym: ~str, node_id: ast:
22942294
llfn: ValueRef) {
22952295
ccx.item_symbols.insert(node_id, sym);
22962296

2297-
if !ccx.reachable.contains(&node_id) {
2297+
if !*ccx.sess.building_library {
22982298
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
22992299
}
23002300

@@ -2504,7 +2504,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
25042504
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
25052505
};
25062506

2507-
if !ccx.reachable.contains(&id) {
2507+
if !*ccx.sess.building_library {
25082508
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
25092509
}
25102510

0 commit comments

Comments
 (0)