Skip to content

Commit dd5ce50

Browse files
---
yaml --- r: 96149 b: refs/heads/dist-snap c: d0872eb h: refs/heads/master i: 96147: 3dfe2d6 v: v3
1 parent 7e491bc commit dd5ce50

File tree

7 files changed

+237
-214
lines changed

7 files changed

+237
-214
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 3d569df41de221ce5b0ffd385caaa9fd6d5fb2ff
9+
refs/heads/dist-snap: d0872eb69272b5e74678b3bc095cc3082f46a5c9
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/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

branches/dist-snap/src/librustc/middle/trans/controlflow.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use middle::trans::base::*;
1414
use middle::trans::build::*;
1515
use middle::trans::callee;
1616
use middle::trans::common::*;
17+
use middle::trans::debuginfo;
1718
use middle::trans::expr;
1819
use middle::ty;
1920
use util::common::indenter;
@@ -75,6 +76,7 @@ pub fn trans_if(bcx: @mut Block,
7576
// if true { .. } [else { .. }]
7677
return do with_scope(bcx, thn.info(), "if_true_then") |bcx| {
7778
let bcx_out = trans_block(bcx, thn, dest);
79+
debuginfo::clear_source_location(bcx.fcx);
7880
trans_block_cleanups(bcx_out, block_cleanups(bcx))
7981
}
8082
} else {
@@ -86,6 +88,7 @@ pub fn trans_if(bcx: @mut Block,
8688
Some(elexpr) => {
8789
return do with_scope(bcx, elexpr.info(), "if_false_then") |bcx| {
8890
let bcx_out = trans_if_else(bcx, elexpr, dest);
91+
debuginfo::clear_source_location(bcx.fcx);
8992
trans_block_cleanups(bcx_out, block_cleanups(bcx))
9093
}
9194
}
@@ -98,6 +101,8 @@ pub fn trans_if(bcx: @mut Block,
98101
let then_bcx_in = scope_block(bcx, thn.info(), "then");
99102

100103
let then_bcx_out = trans_block(then_bcx_in, thn, dest);
104+
105+
debuginfo::clear_source_location(bcx.fcx);
101106
let then_bcx_out = trans_block_cleanups(then_bcx_out,
102107
block_cleanups(then_bcx_in));
103108

@@ -122,6 +127,9 @@ pub fn trans_if(bcx: @mut Block,
122127
debug!("then_bcx_in={}, else_bcx_in={}",
123128
then_bcx_in.to_str(), else_bcx_in.to_str());
124129

130+
// Clear the source location because it is still set to whatever has been translated
131+
// right before.
132+
debuginfo::clear_source_location(else_bcx_in.fcx);
125133
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
126134
return next_bcx;
127135

@@ -139,6 +147,7 @@ pub fn trans_if(bcx: @mut Block,
139147
// would be nice to have a constraint on ifs
140148
_ => else_bcx_in.tcx().sess.bug("strange alternative in if")
141149
};
150+
debuginfo::clear_source_location(else_bcx_in.fcx);
142151
trans_block_cleanups(else_bcx_out, block_cleanups(else_bcx_in))
143152
}
144153
}

branches/dist-snap/src/librustc/middle/trans/debuginfo.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,17 @@ pub fn set_source_location(fcx: &FunctionContext,
509509
}
510510
}
511511

512+
/// Clears the current debug location.
513+
///
514+
/// Instructions generated hereafter won't be assigned a source location.
515+
pub fn clear_source_location(fcx: &FunctionContext) {
516+
if fn_should_be_ignored(fcx) {
517+
return;
518+
}
519+
520+
set_debug_location(fcx.ccx, UnknownLocation);
521+
}
522+
512523
/// Enables emitting source locations for the given functions.
513524
///
514525
/// Since we don't want source locations to be emitted for the function prelude, they are disabled

0 commit comments

Comments
 (0)