Skip to content

Commit 868e3f9

Browse files
committed
Don't try to keep locals off of the stack. Closes #2408.
There were bugs in the code path for initialization of non-spilled locals, the code-path is hit approximately never, and mem2reg can do it for us. I think this will let us kill spill_map.
1 parent d9cddde commit 868e3f9

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,6 +3749,8 @@ fn lval_to_dps(bcx: block, e: @ast::expr, dest: dest) -> block {
37493749
let ty = expr_ty(bcx, e);
37503750
let lv = trans_lval(bcx, e);
37513751
let last_use = (lv.kind == owned && last_use_map.contains_key(e.id));
3752+
#debug["is last use (%s) = %b, %d", expr_to_str(e), last_use,
3753+
lv.kind as int];
37523754
lval_result_to_dps(lv, ty, last_use, dest)
37533755
}
37543756

@@ -4039,29 +4041,10 @@ fn init_local(bcx: block, local: @ast::local) -> block {
40394041
let ty = node_id_type(bcx, local.node.id);
40404042
let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
40414043
some(local_mem(v)) { v }
4042-
some(_) { bcx.tcx().sess.span_bug(local.span,
4044+
_ { bcx.tcx().sess.span_bug(local.span,
40434045
"init_local: Someone forgot to document why it's\
40444046
safe to assume local.node.init must be local_mem!");
4045-
}
4046-
// This is a local that is kept immediate
4047-
none {
4048-
let initexpr = alt local.node.init {
4049-
some({expr, _}) { expr }
4050-
none { bcx.tcx().sess.span_bug(local.span,
4051-
"init_local: late-initialized var appears to \
4052-
be an immediate -- possibly init_local was called \
4053-
without calling alloc_local"); }
4054-
};
4055-
let mut {bcx, val, kind} = trans_temp_lval(bcx, initexpr);
4056-
if kind != temporary {
4057-
if kind == owned { val = Load(bcx, val); }
4058-
let rs = take_ty_immediate(bcx, val, ty);
4059-
bcx = rs.bcx; val = rs.val;
4060-
add_clean_temp(bcx, val, ty);
40614047
}
4062-
bcx.fcx.lllocals.insert(local.node.pat.id, local_imm(val));
4063-
ret bcx;
4064-
}
40654048
};
40664049

40674050
let mut bcx = bcx;
@@ -4341,17 +4324,6 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
43414324
ast::pat_ident(pth, none) { some(path_to_ident(pth)) }
43424325
_ { none }
43434326
};
4344-
// Do not allocate space for locals that can be kept immediate.
4345-
let ccx = cx.ccx();
4346-
if option::is_some(simple_name) &&
4347-
!ccx.maps.mutbl_map.contains_key(local.node.pat.id) &&
4348-
!ccx.maps.spill_map.contains_key(local.node.pat.id) &&
4349-
ty::type_is_immediate(t) {
4350-
alt local.node.init {
4351-
some({op: ast::init_assign, _}) { ret cx; }
4352-
_ {}
4353-
}
4354-
}
43554327
let val = alloc_ty(cx, t);
43564328
if cx.sess().opts.debuginfo {
43574329
option::iter(simple_name) {|name|

0 commit comments

Comments
 (0)