Skip to content

Commit a921dc4

Browse files
committed
rustc: Remove compiler support for __log_level()
This commit removes all internal support for the previously used __log_level() expression. The logging subsystem was previously modified to not rely on this magical expression. This also removes the only other function to use the module_data map in trans, decl_gc_metadata. It appears that this is an ancient function from a GC only used long ago. This does not remove the crate map entirely, as libgreen still uses it to hook in to the event loop provided by libgreen.
1 parent cc6ec8d commit a921dc4

File tree

18 files changed

+22
-284
lines changed

18 files changed

+22
-284
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ impl CFGBuilder {
408408
self.straightline(expr, pred, [e])
409409
}
410410

411-
ast::ExprLogLevel |
412411
ast::ExprMac(..) |
413412
ast::ExprInlineAsm(..) |
414413
ast::ExprFnBlock(..) |

src/librustc/middle/dataflow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
613613
self.walk_exprs([l, r], in_out, loop_scopes);
614614
}
615615

616-
ast::ExprLogLevel |
617616
ast::ExprLit(..) |
618617
ast::ExprPath(..) => {}
619618

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ fn visit_expr(v: &mut LivenessVisitor, expr: &Expr, this: @IrMaps) {
541541

542542
// otherwise, live nodes are not required:
543543
ExprIndex(..) | ExprField(..) | ExprVstore(..) | ExprVec(..) |
544-
ExprCall(..) | ExprMethodCall(..) | ExprTup(..) | ExprLogLevel |
544+
ExprCall(..) | ExprMethodCall(..) | ExprTup(..) |
545545
ExprBinary(..) | ExprAddrOf(..) |
546546
ExprCast(..) | ExprUnary(..) | ExprBreak(_) |
547547
ExprAgain(_) | ExprLit(_) | ExprRet(..) | ExprBlock(..) |
@@ -1271,7 +1271,6 @@ impl Liveness {
12711271
})
12721272
}
12731273

1274-
ExprLogLevel |
12751274
ExprLit(..) => {
12761275
succ
12771276
}
@@ -1521,7 +1520,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
15211520
// no correctness conditions related to liveness
15221521
ExprCall(..) | ExprMethodCall(..) | ExprIf(..) | ExprMatch(..) |
15231522
ExprWhile(..) | ExprLoop(..) | ExprIndex(..) | ExprField(..) |
1524-
ExprVstore(..) | ExprVec(..) | ExprTup(..) | ExprLogLevel |
1523+
ExprVstore(..) | ExprVec(..) | ExprTup(..) |
15251524
ExprBinary(..) |
15261525
ExprCast(..) | ExprUnary(..) | ExprRet(..) | ExprBreak(..) |
15271526
ExprAgain(..) | ExprLit(_) | ExprBlock(..) |

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
469469
ast::ExprUnary(..) |
470470
ast::ExprMethodCall(..) | ast::ExprCast(..) | ast::ExprVstore(..) |
471471
ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
472-
ast::ExprLogLevel | ast::ExprBinary(..) | ast::ExprWhile(..) |
472+
ast::ExprBinary(..) | ast::ExprWhile(..) |
473473
ast::ExprBlock(..) | ast::ExprLoop(..) | ast::ExprMatch(..) |
474474
ast::ExprLit(..) | ast::ExprBreak(..) | ast::ExprMac(..) |
475475
ast::ExprAgain(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |

src/librustc/middle/moves.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ impl VisitContext {
503503
self.use_expr(base, Read);
504504
}
505505

506-
ExprLogLevel |
507506
ExprInlineAsm(..) |
508507
ExprBreak(..) |
509508
ExprAgain(..) |

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use driver::session::{Session, NoDebugInfo, FullDebugInfo};
3232
use driver::driver::OutputFilenames;
3333
use driver::driver::{CrateAnalysis, CrateTranslation};
3434
use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
35-
use lib::llvm::{llvm, True, Vector};
35+
use lib::llvm::{llvm, Vector};
3636
use lib;
3737
use metadata::common::LinkMeta;
3838
use metadata::{csearch, encoder};
@@ -2404,70 +2404,6 @@ pub fn trap(bcx: &Block) {
24042404
}
24052405
}
24062406

2407-
pub fn decl_gc_metadata(ccx: &CrateContext, llmod_id: &str) {
2408-
if !ccx.sess.opts.gc || !ccx.uses_gc {
2409-
return;
2410-
}
2411-
2412-
let gc_metadata_name = ~"_gc_module_metadata_" + llmod_id;
2413-
let gc_metadata = gc_metadata_name.with_c_str(|buf| {
2414-
unsafe {
2415-
llvm::LLVMAddGlobal(ccx.llmod, Type::i32().to_ref(), buf)
2416-
}
2417-
});
2418-
unsafe {
2419-
llvm::LLVMSetGlobalConstant(gc_metadata, True);
2420-
lib::llvm::SetLinkage(gc_metadata, lib::llvm::ExternalLinkage);
2421-
2422-
let mut module_data = ccx.module_data.borrow_mut();
2423-
module_data.get().insert(~"_gc_module_metadata", gc_metadata);
2424-
}
2425-
}
2426-
2427-
pub fn create_module_map(ccx: &CrateContext) -> (ValueRef, uint) {
2428-
let str_slice_type = Type::struct_([Type::i8p(), ccx.int_type], false);
2429-
let elttype = Type::struct_([str_slice_type, ccx.int_type], false);
2430-
let maptype = {
2431-
let module_data = ccx.module_data.borrow();
2432-
Type::array(&elttype, module_data.get().len() as u64)
2433-
};
2434-
let map = "_rust_mod_map".with_c_str(|buf| {
2435-
unsafe {
2436-
llvm::LLVMAddGlobal(ccx.llmod, maptype.to_ref(), buf)
2437-
}
2438-
});
2439-
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
2440-
let mut elts: Vec<ValueRef> = Vec::new();
2441-
2442-
// This is not ideal, but the borrow checker doesn't
2443-
// like the multiple borrows. At least, it doesn't
2444-
// like them on the current snapshot. (2013-06-14)
2445-
let keys = {
2446-
let mut keys = Vec::new();
2447-
let module_data = ccx.module_data.borrow();
2448-
for (k, _) in module_data.get().iter() {
2449-
keys.push(k.clone());
2450-
}
2451-
keys
2452-
};
2453-
2454-
for key in keys.iter() {
2455-
let llstrval = C_str_slice(ccx, token::intern_and_get_ident(*key));
2456-
let module_data = ccx.module_data.borrow();
2457-
let val = *module_data.get().find_equiv(key).unwrap();
2458-
let v_ptr = p2i(ccx, val);
2459-
let elt = C_struct([
2460-
llstrval,
2461-
v_ptr
2462-
], false);
2463-
elts.push(elt);
2464-
}
2465-
unsafe {
2466-
llvm::LLVMSetInitializer(map, C_array(elttype, elts.as_slice()));
2467-
}
2468-
return (map, keys.len())
2469-
}
2470-
24712407
pub fn symname(name: &str, hash: &str, vers: &str) -> ~str {
24722408
let path = [PathName(token::intern(name))];
24732409
link::exported_name(ast_map::Values(path.iter()).chain(None), hash, vers)
@@ -2489,11 +2425,8 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
24892425
mapmeta.crateid.version_or_default())
24902426
};
24912427
2492-
let slicetype = Type::struct_([int_type, int_type], false);
24932428
let maptype = Type::struct_([
24942429
Type::i32(), // version
2495-
slicetype, // child modules
2496-
slicetype, // sub crate-maps
24972430
int_type.ptr_to(), // event loop factory
24982431
], false);
24992432
let map = sym_name.with_c_str(|buf| {
@@ -2513,22 +2446,6 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
25132446
}
25142447
25152448
pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) {
2516-
let mut subcrates: Vec<ValueRef> = Vec::new();
2517-
let mut i = 1;
2518-
let cstore = ccx.sess.cstore;
2519-
while cstore.have_crate_data(i) {
2520-
let cdata = cstore.get_crate_data(i);
2521-
let nm = symname(format!("_rust_crate_map_{}", cdata.name),
2522-
cstore.get_crate_hash(i).as_str(),
2523-
cstore.get_crate_id(i).version_or_default());
2524-
let cr = nm.with_c_str(|buf| {
2525-
unsafe {
2526-
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)
2527-
}
2528-
});
2529-
subcrates.push(p2i(ccx, cr));
2530-
i += 1;
2531-
}
25322449
let event_loop_factory = match ccx.tcx.lang_items.event_loop_factory() {
25332450
Some(did) => unsafe {
25342451
if is_local(did) {
@@ -2545,26 +2462,8 @@ pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) {
25452462
None => C_null(ccx.int_type.ptr_to())
25462463
};
25472464
unsafe {
2548-
let maptype = Type::array(&ccx.int_type, subcrates.len() as u64);
2549-
let vec_elements = "_crate_map_child_vectors".with_c_str(|buf| {
2550-
llvm::LLVMAddGlobal(ccx.llmod, maptype.to_ref(), buf)
2551-
});
2552-
lib::llvm::SetLinkage(vec_elements, lib::llvm::InternalLinkage);
2553-
2554-
llvm::LLVMSetInitializer(vec_elements,
2555-
C_array(ccx.int_type, subcrates.as_slice()));
2556-
let (mod_map, mod_count) = create_module_map(ccx);
2557-
25582465
llvm::LLVMSetInitializer(map, C_struct(
25592466
[C_i32(2),
2560-
C_struct([
2561-
p2i(ccx, mod_map),
2562-
C_uint(ccx, mod_count)
2563-
], false),
2564-
C_struct([
2565-
p2i(ccx, vec_elements),
2566-
C_uint(ccx, subcrates.len())
2567-
], false),
25682467
event_loop_factory,
25692468
], false));
25702469
}
@@ -2667,7 +2566,6 @@ pub fn trans_crate(sess: session::Session,
26672566
trans_mod(ccx, &krate.module);
26682567
}
26692568
2670-
decl_gc_metadata(ccx, llmod_id);
26712569
fill_crate_map(ccx, ccx.crate_map);
26722570
26732571
// win32: wart with exporting crate_map symbol

src/librustc/middle/trans/context.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ pub struct CrateContext {
9595
// Cache of closure wrappers for bare fn's.
9696
closure_bare_wrapper_cache: RefCell<HashMap<ValueRef, ValueRef>>,
9797

98-
module_data: RefCell<HashMap<~str, ValueRef>>,
9998
lltypes: RefCell<HashMap<ty::t, Type>>,
10099
llsizingtypes: RefCell<HashMap<ty::t, Type>>,
101100
adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
@@ -207,7 +206,6 @@ impl CrateContext {
207206
extern_const_values: RefCell::new(DefIdMap::new()),
208207
impl_method_cache: RefCell::new(HashMap::new()),
209208
closure_bare_wrapper_cache: RefCell::new(HashMap::new()),
210-
module_data: RefCell::new(HashMap::new()),
211209
lltypes: RefCell::new(HashMap::new()),
212210
llsizingtypes: RefCell::new(HashMap::new()),
213211
adt_reprs: RefCell::new(HashMap::new()),

src/librustc/middle/trans/debuginfo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,6 @@ fn populate_scope_map(cx: &CrateContext,
25392539
scope_map.insert(exp.id, scope_stack.last().unwrap().scope_metadata);
25402540

25412541
match exp.node {
2542-
ast::ExprLogLevel |
25432542
ast::ExprLit(_) |
25442543
ast::ExprBreak(_) |
25452544
ast::ExprAgain(_) |

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
#[allow(non_camel_case_types)];
3535

3636
use back::abi;
37-
use back::link;
38-
use lib::llvm::{ValueRef, llvm, SetLinkage, False};
37+
use lib::llvm::{ValueRef, llvm};
3938
use lib;
4039
use metadata::csearch;
4140
use middle::trans::_match;
@@ -74,9 +73,7 @@ use middle::trans::type_::Type;
7473
use std::vec;
7574
use std::vec_ng::Vec;
7675
use syntax::ast;
77-
use syntax::ast_map;
7876
use syntax::codemap;
79-
use syntax::parse::token;
8077
use syntax::print::pprust::{expr_to_str};
8178

8279
// Destinations
@@ -455,9 +452,6 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
455452
// Datum output mode means this is a scalar cast:
456453
trans_imm_cast(bcx, val, expr.id)
457454
}
458-
ast::ExprLogLevel => {
459-
trans_log_level(bcx)
460-
}
461455
_ => {
462456
bcx.tcx().sess.span_bug(
463457
expr.span,
@@ -1671,64 +1665,6 @@ fn trans_assign_op<'a>(
16711665
return result_datum.store_to(bcx, dst_datum.val);
16721666
}
16731667

1674-
fn trans_log_level<'a>(bcx: &'a Block<'a>) -> DatumBlock<'a, Expr> {
1675-
let _icx = push_ctxt("trans_log_level");
1676-
let ccx = bcx.ccx();
1677-
1678-
let (modpath, modname) = {
1679-
let srccrate = {
1680-
let external_srcs = ccx.external_srcs.borrow();
1681-
match external_srcs.get().find(&bcx.fcx.id) {
1682-
Some(&src) => {
1683-
ccx.sess.cstore.get_crate_data(src.krate).name.clone()
1684-
}
1685-
None => ccx.link_meta.crateid.name.to_str(),
1686-
}
1687-
};
1688-
bcx.tcx().map.with_path(bcx.fcx.id, |path| {
1689-
let first = ast_map::PathMod(token::intern(srccrate));
1690-
let mut path = Some(first).move_iter().chain(path).filter(|e| {
1691-
match *e {
1692-
ast_map::PathMod(_) => true,
1693-
_ => false
1694-
}
1695-
});
1696-
let modpath: Vec<ast_map::PathElem> = path.collect();
1697-
let modname = ast_map::path_to_str(ast_map::Values(modpath.iter()));
1698-
(modpath, modname)
1699-
})
1700-
};
1701-
1702-
let module_data_exists;
1703-
{
1704-
let module_data = ccx.module_data.borrow();
1705-
module_data_exists = module_data.get().contains_key(&modname);
1706-
}
1707-
1708-
let global = if module_data_exists {
1709-
let mut module_data = ccx.module_data.borrow_mut();
1710-
module_data.get().get_copy(&modname)
1711-
} else {
1712-
let s = link::mangle_internal_name_by_path_and_seq(
1713-
ast_map::Values(modpath.iter()).chain(None), "loglevel");
1714-
let global;
1715-
unsafe {
1716-
global = s.with_c_str(|buf| {
1717-
llvm::LLVMAddGlobal(ccx.llmod, Type::i32().to_ref(), buf)
1718-
});
1719-
llvm::LLVMSetGlobalConstant(global, False);
1720-
llvm::LLVMSetInitializer(global, C_null(Type::i32()));
1721-
lib::llvm::SetLinkage(global, lib::llvm::InternalLinkage);
1722-
}
1723-
{
1724-
let mut module_data = ccx.module_data.borrow_mut();
1725-
module_data.get().insert(modname, global);
1726-
global
1727-
}
1728-
};
1729-
1730-
immediate_rvalue_bcx(bcx, Load(bcx, global), ty::mk_u32()).to_expr_datumblock()
1731-
}
17321668

17331669
fn auto_ref<'a>(bcx: &'a Block<'a>,
17341670
datum: Datum<Expr>,

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3391,7 +3391,6 @@ pub fn expr_kind(tcx: ctxt,
33913391

33923392
ast::ExprForLoop(..) => fail!("non-desugared expr_for_loop"),
33933393

3394-
ast::ExprLogLevel |
33953394
ast::ExprLit(_) | // Note: LitStr is carved out above
33963395
ast::ExprUnary(..) |
33973396
ast::ExprAddrOf(..) |

src/librustc/middle/typeck/check/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,9 +2848,6 @@ fn check_expr_with_unifier(fcx: @FnCtxt,
28482848
}
28492849
fcx.write_bot(id);
28502850
}
2851-
ast::ExprLogLevel => {
2852-
fcx.write_ty(id, ty::mk_u32())
2853-
}
28542851
ast::ExprParen(a) => {
28552852
check_expr_with_opt_hint_and_lvalue_pref(fcx, a, expected, lvalue_pref);
28562853
fcx.write_ty(id, fcx.expr_ty(a));

0 commit comments

Comments
 (0)