Fix leaking arg slots on tail calls. Closes #160.

This commit is contained in:
Graydon Hoare 2010-09-13 13:37:24 -07:00
parent 67aa39e1ef
commit bc646d01c5
3 changed files with 14 additions and 0 deletions

View File

@ -533,6 +533,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
str-concat.rs \
str-idx.rs \
tag.rs \
tail-call-arg-leak.rs \
tail-cps.rs \
tail-direct.rs \
task-comm.rs \

View File

@ -4219,6 +4219,8 @@ let trans_visitor
(Printf.sprintf "copy args for tail call to %s" (logname ())));
copy_fn_args true true CLONE_none call;
drop_slots_at_curr_stmt();
iflog (fun _ -> annotate "drop args");
iter_arg_slots cx (current_fn()) callee_drop_slot;
abi.Abi.abi_emit_fn_tail_call (emitter())
(force_sz (current_fn_callsz()))
caller_argsz callee_code callee_argsz;

View File

@ -0,0 +1,11 @@
// use of tail calls causes arg slot leaks, issue #160.
fn inner(str dummy, bool b) {
if (b) {
be inner(dummy, false);
}
}
fn main() {
inner("hi", true);
}