Skip to content

Remove unused upcalls #10708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/librustc/back/upcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,10 @@ use middle::trans::type_::Type;
use lib::llvm::{ModuleRef, ValueRef};

pub struct Upcalls {
trace: ValueRef,
rust_personality: ValueRef,
reset_stack_limit: ValueRef
}

macro_rules! upcall (
(fn $name:ident($($arg:expr),+) -> $ret:expr) => ({
let fn_ty = Type::func([ $($arg),* ], &$ret);
base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty)
});
(nothrow fn $name:ident($($arg:expr),+) -> $ret:expr) => ({
let fn_ty = Type::func([ $($arg),* ], &$ret);
let decl = base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty);
base::set_no_unwind(decl);
decl
});
(nothrow fn $name:ident -> $ret:expr) => ({
let fn_ty = Type::func([], &$ret);
let decl = base::decl_cdecl_fn(llmod, ~"upcall_" + stringify!($name), fn_ty);
Expand All @@ -39,13 +27,9 @@ macro_rules! upcall (
})
)

pub fn declare_upcalls(targ_cfg: @session::config, llmod: ModuleRef) -> @Upcalls {
let opaque_ptr = Type::i8().ptr_to();
let int_ty = Type::int(targ_cfg.arch);

pub fn declare_upcalls(_targ_cfg: @session::config,
llmod: ModuleRef) -> @Upcalls {
@Upcalls {
trace: upcall!(fn trace(opaque_ptr, opaque_ptr, int_ty) -> Type::void()),
rust_personality: upcall!(nothrow fn rust_personality -> Type::i32()),
reset_stack_limit: upcall!(nothrow fn reset_stack_limit -> Type::void())
}
}
49 changes: 23 additions & 26 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,29 @@ pub static time_llvm_passes: uint = 1 << 3;
pub static trans_stats: uint = 1 << 4;
pub static asm_comments: uint = 1 << 5;
pub static no_verify: uint = 1 << 6;
pub static trace: uint = 1 << 7;
pub static coherence: uint = 1 << 8;
pub static borrowck_stats: uint = 1 << 9;
pub static borrowck_note_pure: uint = 1 << 10;
pub static borrowck_note_loan: uint = 1 << 11;
pub static no_landing_pads: uint = 1 << 12;
pub static debug_llvm: uint = 1 << 13;
pub static count_type_sizes: uint = 1 << 14;
pub static meta_stats: uint = 1 << 15;
pub static no_opt: uint = 1 << 16;
pub static gc: uint = 1 << 17;
pub static jit: uint = 1 << 18;
pub static debug_info: uint = 1 << 19;
pub static extra_debug_info: uint = 1 << 20;
pub static statik: uint = 1 << 21;
pub static print_link_args: uint = 1 << 22;
pub static no_debug_borrows: uint = 1 << 23;
pub static lint_llvm: uint = 1 << 24;
pub static print_llvm_passes: uint = 1 << 25;
pub static no_vectorize_loops: uint = 1 << 26;
pub static no_vectorize_slp: uint = 1 << 27;
pub static no_prepopulate_passes: uint = 1 << 28;
pub static use_softfp: uint = 1 << 29;
pub static gen_crate_map: uint = 1 << 30;
pub static coherence: uint = 1 << 7;
pub static borrowck_stats: uint = 1 << 8;
pub static borrowck_note_pure: uint = 1 << 9;
pub static borrowck_note_loan: uint = 1 << 10;
pub static no_landing_pads: uint = 1 << 11;
pub static debug_llvm: uint = 1 << 12;
pub static count_type_sizes: uint = 1 << 13;
pub static meta_stats: uint = 1 << 14;
pub static no_opt: uint = 1 << 15;
pub static gc: uint = 1 << 16;
pub static jit: uint = 1 << 17;
pub static debug_info: uint = 1 << 18;
pub static extra_debug_info: uint = 1 << 19;
pub static statik: uint = 1 << 20;
pub static print_link_args: uint = 1 << 21;
pub static no_debug_borrows: uint = 1 << 22;
pub static lint_llvm: uint = 1 << 23;
pub static print_llvm_passes: uint = 1 << 24;
pub static no_vectorize_loops: uint = 1 << 25;
pub static no_vectorize_slp: uint = 1 << 26;
pub static no_prepopulate_passes: uint = 1 << 27;
pub static use_softfp: uint = 1 << 28;
pub static gen_crate_map: uint = 1 << 29;

pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
~[("verbose", "in general, enable more debug printouts", verbose),
Expand All @@ -87,7 +86,6 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
("trans-stats", "gather trans statistics", trans_stats),
("asm-comments", "generate comments into the assembly (may change behavior)", asm_comments),
("no-verify", "skip LLVM verification", no_verify),
("trace", "emit trace logs", trace),
("coherence", "perform coherence checking", coherence),
("borrowck-stats", "gather borrowck statistics", borrowck_stats),
("borrowck-note-pure", "note where purity is req'd",
Expand Down Expand Up @@ -310,7 +308,6 @@ impl Session_ {
pub fn asm_comments(&self) -> bool { self.debugging_opt(asm_comments) }
pub fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
pub fn lint_llvm(&self) -> bool { self.debugging_opt(lint_llvm) }
pub fn trace(&self) -> bool { self.debugging_opt(trace) }
pub fn coherence(&self) -> bool { self.debugging_opt(coherence) }
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
pub fn borrowck_note_pure(&self) -> bool {
Expand Down
39 changes: 0 additions & 39 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,6 @@ pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
// The landing pad block is a cleanup
SetCleanup(pad_bcx, llretval);

// Because we may have unwound across a stack boundary, we must call into
// the runtime to figure out which stack segment we are on and place the
// stack limit back into the TLS.
Call(pad_bcx, bcx.ccx().upcalls.reset_stack_limit, [], []);

// We store the retval in a function-central alloca, so that calls to
// Resume can find it.
match bcx.fcx.personality {
Expand Down Expand Up @@ -1097,28 +1092,6 @@ pub fn load_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
return v;
}

pub fn trans_trace(bcx: @mut Block, sp_opt: Option<Span>, trace_str: @str) {
if !bcx.sess().trace() { return; }
let _icx = push_ctxt("trans_trace");
add_comment(bcx, trace_str);
let V_trace_str = C_cstr(bcx.ccx(), trace_str);
let (V_filename, V_line) = match sp_opt {
Some(sp) => {
let sess = bcx.sess();
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
(C_cstr(bcx.ccx(), loc.file.name), loc.line as int)
}
None => {
(C_cstr(bcx.ccx(), @"<runtime>"), 0)
}
};
let ccx = bcx.ccx();
let V_trace_str = PointerCast(bcx, V_trace_str, Type::i8p());
let V_filename = PointerCast(bcx, V_filename, Type::i8p());
let args = ~[V_trace_str, V_filename, C_int(ccx, V_line)];
Call(bcx, ccx.upcalls.trace, args, []);
}

pub fn ignore_lhs(_bcx: @mut Block, local: &ast::Local) -> bool {
match local.pat.node {
ast::PatWild => true, _ => false
Expand Down Expand Up @@ -1313,12 +1286,6 @@ pub fn cleanup_and_leave(bcx: @mut Block,
loop {
debug!("cleanup_and_leave: leaving {}", cur.to_str());

if bcx.sess().trace() {
trans_trace(
bcx, None,
(format!("cleanup_and_leave({})", cur.to_str())).to_managed());
}

let mut cur_scope = cur.scope;
loop {
cur_scope = match cur_scope {
Expand Down Expand Up @@ -1387,12 +1354,6 @@ pub fn cleanup_block(bcx: @mut Block, upto: Option<BasicBlockRef>) -> @mut Block
loop {
debug!("cleanup_block: {}", cur.to_str());

if bcx.sess().trace() {
trans_trace(
bcx, None,
(format!("cleanup_block({})", cur.to_str())).to_managed());
}

let mut cur_scope = cur.scope;
loop {
cur_scope = match cur_scope {
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@ fn trans_to_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
let _icx = push_ctxt("trans_rvalue_datum_unadjusted");

trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));

match expr.node {
ast::ExprPath(_) | ast::ExprSelf => {
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
Expand Down Expand Up @@ -625,8 +623,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> @mut Block
return bcx;
}

trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));

match expr.node {
ast::ExprBreak(label_opt) => {
return controlflow::trans_break(bcx, label_opt);
Expand Down Expand Up @@ -676,8 +672,6 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: &ast::Expr,
let _icx = push_ctxt("trans_rvalue_dps_unadjusted");
let tcx = bcx.tcx();

trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));

match expr.node {
ast::ExprParen(e) => {
return trans_rvalue_dps_unadjusted(bcx, e, dest);
Expand Down Expand Up @@ -895,8 +889,6 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
debug!("trans_lvalue(expr={})", bcx.expr_to_str(expr));
let _indenter = indenter();

trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));

return match expr.node {
ast::ExprParen(e) => {
trans_lvalue_unadjusted(bcx, e)
Expand Down
22 changes: 0 additions & 22 deletions src/librustc/middle/trans/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,3 @@ macro_rules! unpack_result(
}
)
)

macro_rules! trace_span(
($bcx: ident, $sp: expr, $str: expr) => (
{
let bcx = $bcx;
if bcx.sess().trace() {
trans_trace(bcx, Some($sp), $str);
}
}
)
)

macro_rules! trace(
($bcx: ident, $str: expr) => (
{
let bcx = $bcx;
if bcx.sess().trace() {
trans_trace(bcx, None, $str);
}
}
)
)
7 changes: 0 additions & 7 deletions src/librustc/middle/trans/write_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ fn root(datum: &Datum,
debug!("write_guard::root(root_key={:?}, root_info={:?}, datum={:?})",
root_key, root_info, datum.to_str(bcx.ccx()));

if bcx.sess().trace() {
trans_trace(
bcx, None,
(format!("preserving until end of scope {}",
root_info.scope)).to_managed());
}

// First, root the datum. Note that we must zero this value,
// because sometimes we root on one path but not another.
// See e.g. #4904.
Expand Down
3 changes: 2 additions & 1 deletion src/rt/rust_upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct s_rust_personality_args {
struct _Unwind_Context *context;
};

void
static void
upcall_s_rust_personality(struct s_rust_personality_args *args) {
args->retval = PERSONALITY_FUNC(args->version,
args->actions,
Expand All @@ -78,6 +78,7 @@ upcall_rust_personality(int version,
return args.retval;
}

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