Skip to content

Commit 17a951c

Browse files
committed
Remove unused upcalls
The main one removed is rust_upcall_reset_stack_limit (continuation of #10156), and this also removes the upcall_trace function. The was hidden behind a `-Z trace` flag, but if you attempt to use this now you'll get a linker error because there is no implementation of the 'upcall_trace' function. Due to this no longer working, I decided to remove it entirely from the compiler (I'm also a little unsure on what it did in the first place).
1 parent 6b34ba2 commit 17a951c

File tree

11 files changed

+46
-133
lines changed

11 files changed

+46
-133
lines changed

mk/llvm.mk

+2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ endif
3737
# dependencies. In these cases, commit a change that touches
3838
# the stamp in the source dir.
3939
$$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
40+
@$$(call E, make: cleaning llvm)
4041
$(Q)$(MAKE) clean-llvm
42+
@$$(call E, make: done cleaning llvm)
4143
touch $$@
4244

4345
endef

src/librustc/back/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ pub fn sanitize(s: &str) -> ~str {
598598
',' => result.push_str("$C$"),
599599

600600
// '.' doesn't occur in types and functions, so reuse it
601-
// for ':'
602-
':' => result.push_char('.'),
601+
// for ':' and '-'
602+
'-' | ':' => result.push_char('.'),
603603

604604
// These are legal symbols
605605
'a' .. 'z'

src/librustc/back/upcall.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,10 @@ use middle::trans::type_::Type;
1515
use lib::llvm::{ModuleRef, ValueRef};
1616

1717
pub struct Upcalls {
18-
trace: ValueRef,
1918
rust_personality: ValueRef,
20-
reset_stack_limit: ValueRef
2119
}
2220

2321
macro_rules! upcall (
24-
(fn $name:ident($($arg:expr),+) -> $ret:expr) => ({
25-
let fn_ty = Type::func([ $($arg),* ], &$ret);
26-
base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty)
27-
});
28-
(nothrow fn $name:ident($($arg:expr),+) -> $ret:expr) => ({
29-
let fn_ty = Type::func([ $($arg),* ], &$ret);
30-
let decl = base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty);
31-
base::set_no_unwind(decl);
32-
decl
33-
});
3422
(nothrow fn $name:ident -> $ret:expr) => ({
3523
let fn_ty = Type::func([], &$ret);
3624
let decl = base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty);
@@ -39,13 +27,9 @@ macro_rules! upcall (
3927
})
4028
)
4129

42-
pub fn declare_upcalls(targ_cfg: @session::config, llmod: ModuleRef) -> @Upcalls {
43-
let opaque_ptr = Type::i8().ptr_to();
44-
let int_ty = Type::int(targ_cfg.arch);
45-
30+
pub fn declare_upcalls(_targ_cfg: @session::config,
31+
llmod: ModuleRef) -> @Upcalls {
4632
@Upcalls {
47-
trace: upcall!(fn trace(opaque_ptr, opaque_ptr, int_ty) -> Type::void()),
4833
rust_personality: upcall!(nothrow fn rust_personality -> Type::i32()),
49-
reset_stack_limit: upcall!(nothrow fn reset_stack_limit -> Type::void())
5034
}
5135
}

src/librustc/driver/session.rs

+22-25
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,28 @@ pub static time_llvm_passes: uint = 1 << 3;
4444
pub static trans_stats: uint = 1 << 4;
4545
pub static asm_comments: uint = 1 << 5;
4646
pub static no_verify: uint = 1 << 6;
47-
pub static trace: uint = 1 << 7;
48-
pub static coherence: uint = 1 << 8;
49-
pub static borrowck_stats: uint = 1 << 9;
50-
pub static borrowck_note_pure: uint = 1 << 10;
51-
pub static borrowck_note_loan: uint = 1 << 11;
52-
pub static no_landing_pads: uint = 1 << 12;
53-
pub static debug_llvm: uint = 1 << 13;
54-
pub static count_type_sizes: uint = 1 << 14;
55-
pub static meta_stats: uint = 1 << 15;
56-
pub static no_opt: uint = 1 << 16;
57-
pub static gc: uint = 1 << 17;
58-
pub static debug_info: uint = 1 << 18;
59-
pub static extra_debug_info: uint = 1 << 19;
60-
pub static print_link_args: uint = 1 << 20;
61-
pub static no_debug_borrows: uint = 1 << 21;
62-
pub static lint_llvm: uint = 1 << 22;
63-
pub static print_llvm_passes: uint = 1 << 23;
64-
pub static no_vectorize_loops: uint = 1 << 24;
65-
pub static no_vectorize_slp: uint = 1 << 25;
66-
pub static no_prepopulate_passes: uint = 1 << 26;
67-
pub static use_softfp: uint = 1 << 27;
68-
pub static gen_crate_map: uint = 1 << 28;
69-
pub static prefer_dynamic: uint = 1 << 29;
47+
pub static coherence: uint = 1 << 7;
48+
pub static borrowck_stats: uint = 1 << 8;
49+
pub static borrowck_note_pure: uint = 1 << 9;
50+
pub static borrowck_note_loan: uint = 1 << 10;
51+
pub static no_landing_pads: uint = 1 << 11;
52+
pub static debug_llvm: uint = 1 << 12;
53+
pub static count_type_sizes: uint = 1 << 13;
54+
pub static meta_stats: uint = 1 << 14;
55+
pub static no_opt: uint = 1 << 15;
56+
pub static gc: uint = 1 << 16;
57+
pub static debug_info: uint = 1 << 17;
58+
pub static extra_debug_info: uint = 1 << 18;
59+
pub static print_link_args: uint = 1 << 19;
60+
pub static no_debug_borrows: uint = 1 << 20;
61+
pub static lint_llvm: uint = 1 << 21;
62+
pub static print_llvm_passes: uint = 1 << 22;
63+
pub static no_vectorize_loops: uint = 1 << 23;
64+
pub static no_vectorize_slp: uint = 1 << 24;
65+
pub static no_prepopulate_passes: uint = 1 << 25;
66+
pub static use_softfp: uint = 1 << 26;
67+
pub static gen_crate_map: uint = 1 << 27;
68+
pub static prefer_dynamic: uint = 1 << 28;
7069

7170
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
7271
~[("verbose", "in general, enable more debug printouts", verbose),
@@ -78,7 +77,6 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
7877
("trans-stats", "gather trans statistics", trans_stats),
7978
("asm-comments", "generate comments into the assembly (may change behavior)", asm_comments),
8079
("no-verify", "skip LLVM verification", no_verify),
81-
("trace", "emit trace logs", trace),
8280
("coherence", "perform coherence checking", coherence),
8381
("borrowck-stats", "gather borrowck statistics", borrowck_stats),
8482
("borrowck-note-pure", "note where purity is req'd",
@@ -308,7 +306,6 @@ impl Session_ {
308306
pub fn asm_comments(&self) -> bool { self.debugging_opt(asm_comments) }
309307
pub fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
310308
pub fn lint_llvm(&self) -> bool { self.debugging_opt(lint_llvm) }
311-
pub fn trace(&self) -> bool { self.debugging_opt(trace) }
312309
pub fn coherence(&self) -> bool { self.debugging_opt(coherence) }
313310
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
314311
pub fn borrowck_note_pure(&self) -> bool {

src/librustc/middle/trans/base.rs

+14-48
Original file line numberDiff line numberDiff line change
@@ -1018,11 +1018,6 @@ pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
10181018
// The landing pad block is a cleanup
10191019
SetCleanup(pad_bcx, llretval);
10201020

1021-
// Because we may have unwound across a stack boundary, we must call into
1022-
// the runtime to figure out which stack segment we are on and place the
1023-
// stack limit back into the TLS.
1024-
Call(pad_bcx, bcx.ccx().upcalls.reset_stack_limit, [], []);
1025-
10261021
// We store the retval in a function-central alloca, so that calls to
10271022
// Resume can find it.
10281023
match bcx.fcx.personality {
@@ -1097,28 +1092,6 @@ pub fn load_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
10971092
return v;
10981093
}
10991094

1100-
pub fn trans_trace(bcx: @mut Block, sp_opt: Option<Span>, trace_str: @str) {
1101-
if !bcx.sess().trace() { return; }
1102-
let _icx = push_ctxt("trans_trace");
1103-
add_comment(bcx, trace_str);
1104-
let V_trace_str = C_cstr(bcx.ccx(), trace_str);
1105-
let (V_filename, V_line) = match sp_opt {
1106-
Some(sp) => {
1107-
let sess = bcx.sess();
1108-
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
1109-
(C_cstr(bcx.ccx(), loc.file.name), loc.line as int)
1110-
}
1111-
None => {
1112-
(C_cstr(bcx.ccx(), @"<runtime>"), 0)
1113-
}
1114-
};
1115-
let ccx = bcx.ccx();
1116-
let V_trace_str = PointerCast(bcx, V_trace_str, Type::i8p());
1117-
let V_filename = PointerCast(bcx, V_filename, Type::i8p());
1118-
let args = ~[V_trace_str, V_filename, C_int(ccx, V_line)];
1119-
Call(bcx, ccx.upcalls.trace, args, []);
1120-
}
1121-
11221095
pub fn ignore_lhs(_bcx: @mut Block, local: &ast::Local) -> bool {
11231096
match local.pat.node {
11241097
ast::PatWild => true, _ => false
@@ -1313,12 +1286,6 @@ pub fn cleanup_and_leave(bcx: @mut Block,
13131286
loop {
13141287
debug!("cleanup_and_leave: leaving {}", cur.to_str());
13151288

1316-
if bcx.sess().trace() {
1317-
trans_trace(
1318-
bcx, None,
1319-
(format!("cleanup_and_leave({})", cur.to_str())).to_managed());
1320-
}
1321-
13221289
let mut cur_scope = cur.scope;
13231290
loop {
13241291
cur_scope = match cur_scope {
@@ -1387,12 +1354,6 @@ pub fn cleanup_block(bcx: @mut Block, upto: Option<BasicBlockRef>) -> @mut Block
13871354
loop {
13881355
debug!("cleanup_block: {}", cur.to_str());
13891356

1390-
if bcx.sess().trace() {
1391-
trans_trace(
1392-
bcx, None,
1393-
(format!("cleanup_block({})", cur.to_str())).to_managed());
1394-
}
1395-
13961357
let mut cur_scope = cur.scope;
13971358
loop {
13981359
cur_scope = match cur_scope {
@@ -2961,6 +2922,11 @@ pub fn create_module_map(ccx: &mut CrateContext) -> (ValueRef, uint) {
29612922
return (map, keys.len())
29622923
}
29632924

2925+
pub fn symname(sess: session::Session, name: &str,
2926+
hash: &str, vers: &str) -> ~str {
2927+
let elt = path_name(sess.ident_of(name));
2928+
link::exported_name(sess, ~[elt], hash, vers)
2929+
}
29642930

29652931
pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29662932
llmod: ModuleRef) -> ValueRef {
@@ -2969,13 +2935,14 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29692935
let mut n_subcrates = 1;
29702936
let cstore = sess.cstore;
29712937
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
2972-
let mapname = if *sess.building_library && !sess.gen_crate_map() {
2973-
format!("{}_{}_{}", mapmeta.name, mapmeta.vers, mapmeta.extras_hash)
2938+
let is_top = !*sess.building_library || sess.gen_crate_map();
2939+
let sym_name = if is_top {
2940+
~"_rust_crate_map_toplevel"
29742941
} else {
2975-
~"toplevel"
2942+
symname(sess, "_rust_crate_map_" + mapmeta.name, mapmeta.extras_hash,
2943+
mapmeta.vers)
29762944
};
29772945

2978-
let sym_name = ~"_rust_crate_map_" + mapname;
29792946
let slicetype = Type::struct_([int_type, int_type], false);
29802947
let maptype = Type::struct_([
29812948
Type::i32(), // version
@@ -2990,7 +2957,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29902957
});
29912958
// On windows we'd like to export the toplevel cratemap
29922959
// such that we can find it from libstd.
2993-
if targ_cfg.os == OsWin32 && "toplevel" == mapname {
2960+
if targ_cfg.os == OsWin32 && is_top {
29942961
lib::llvm::SetLinkage(map, lib::llvm::DLLExportLinkage);
29952962
} else {
29962963
lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage);
@@ -3005,10 +2972,9 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
30052972
let cstore = ccx.sess.cstore;
30062973
while cstore::have_crate_data(cstore, i) {
30072974
let cdata = cstore::get_crate_data(cstore, i);
3008-
let nm = format!("_rust_crate_map_{}_{}_{}",
3009-
cdata.name,
3010-
cstore::get_crate_vers(cstore, i),
3011-
cstore::get_crate_hash(cstore, i));
2975+
let nm = symname(ccx.sess, format!("_rust_crate_map_{}", cdata.name),
2976+
cstore::get_crate_hash(cstore, i),
2977+
cstore::get_crate_vers(cstore, i));
30122978
let cr = nm.with_c_str(|buf| {
30132979
unsafe {
30142980
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)

src/librustc/middle/trans/expr.rs

-8
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,6 @@ fn trans_to_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
567567
fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
568568
let _icx = push_ctxt("trans_rvalue_datum_unadjusted");
569569

570-
trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));
571-
572570
match expr.node {
573571
ast::ExprPath(_) | ast::ExprSelf => {
574572
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
@@ -625,8 +623,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> @mut Block
625623
return bcx;
626624
}
627625

628-
trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));
629-
630626
match expr.node {
631627
ast::ExprBreak(label_opt) => {
632628
return controlflow::trans_break(bcx, label_opt);
@@ -676,8 +672,6 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: &ast::Expr,
676672
let _icx = push_ctxt("trans_rvalue_dps_unadjusted");
677673
let tcx = bcx.tcx();
678674

679-
trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));
680-
681675
match expr.node {
682676
ast::ExprParen(e) => {
683677
return trans_rvalue_dps_unadjusted(bcx, e, dest);
@@ -895,8 +889,6 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
895889
debug!("trans_lvalue(expr={})", bcx.expr_to_str(expr));
896890
let _indenter = indenter();
897891

898-
trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));
899-
900892
return match expr.node {
901893
ast::ExprParen(e) => {
902894
trans_lvalue_unadjusted(bcx, e)

src/librustc/middle/trans/macros.rs

-22
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,3 @@ macro_rules! unpack_result(
2929
}
3030
)
3131
)
32-
33-
macro_rules! trace_span(
34-
($bcx: ident, $sp: expr, $str: expr) => (
35-
{
36-
let bcx = $bcx;
37-
if bcx.sess().trace() {
38-
trans_trace(bcx, Some($sp), $str);
39-
}
40-
}
41-
)
42-
)
43-
44-
macro_rules! trace(
45-
($bcx: ident, $str: expr) => (
46-
{
47-
let bcx = $bcx;
48-
if bcx.sess().trace() {
49-
trans_trace(bcx, None, $str);
50-
}
51-
}
52-
)
53-
)

src/librustc/middle/trans/write_guard.rs

-7
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ fn root(datum: &Datum,
114114
debug!("write_guard::root(root_key={:?}, root_info={:?}, datum={:?})",
115115
root_key, root_info, datum.to_str(bcx.ccx()));
116116

117-
if bcx.sess().trace() {
118-
trans_trace(
119-
bcx, None,
120-
(format!("preserving until end of scope {}",
121-
root_info.scope)).to_managed());
122-
}
123-
124117
// First, root the datum. Note that we must zero this value,
125118
// because sometimes we root on one path but not another.
126119
// See e.g. #4904.

src/llvm

Submodule llvm updated 952 files

src/rt/rust_upcall.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct s_rust_personality_args {
5151
struct _Unwind_Context *context;
5252
};
5353

54-
void
54+
static void
5555
upcall_s_rust_personality(struct s_rust_personality_args *args) {
5656
args->retval = PERSONALITY_FUNC(args->version,
5757
args->actions,
@@ -78,6 +78,7 @@ upcall_rust_personality(int version,
7878
return args.retval;
7979
}
8080

81+
// NOTE: remove after stage0
8182
// Landing pads need to call this to insert the
8283
// correct limit into TLS.
8384
// NB: This must run on the Rust stack because it

src/rustllvm/llvm-auto-clean-trigger

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2013-11-19
4+
2013-12-05

0 commit comments

Comments
 (0)