Skip to content

Commit 4fba02c

Browse files
committed
Invoke upcall_fail
This allows landing pads to be generated around fail statements Issue #236
1 parent 4c9eee8 commit 4fba02c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/comp/middle/trans.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -3794,14 +3794,25 @@ fn trans_call(in_cx: &@block_ctxt, f: &@ast::expr,
37943794
ret rslt(bcx, retval);
37953795
}
37963796

3797+
fn invoke(bcx: &@block_ctxt, llfn: ValueRef,
3798+
llargs: &[ValueRef]) -> result {
3799+
ret invoke_(bcx, llfn, llargs, Invoke);
3800+
}
3801+
37973802
fn invoke_fastcall(bcx: &@block_ctxt, llfn: ValueRef,
37983803
llargs: &[ValueRef]) -> result {
3804+
ret invoke_(bcx, llfn, llargs, FastInvoke);
3805+
}
37993806

3807+
fn invoke_(bcx: &@block_ctxt, llfn: ValueRef,
3808+
llargs: &[ValueRef],
3809+
invoker: fn(&@block_ctxt, ValueRef, &[ValueRef],
3810+
BasicBlockRef, BasicBlockRef) -> ValueRef) -> result {
38003811
let normal_bcx = new_sub_block_ctxt(bcx, "normal return");
38013812
let unwind_bcx = new_sub_block_ctxt(bcx, "unwind");
3802-
let retval = FastInvoke(bcx, llfn, llargs,
3803-
normal_bcx.llbb,
3804-
unwind_bcx.llbb);
3813+
let retval = invoker(bcx, llfn, llargs,
3814+
normal_bcx.llbb,
3815+
unwind_bcx.llbb);
38053816
trans_landing_pad(unwind_bcx);
38063817
ret rslt(normal_bcx, retval);
38073818
}
@@ -4291,7 +4302,7 @@ fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t<span>,
42914302
let V_str = PointerCast(cx, V_fail_str, T_ptr(T_i8()));
42924303
V_filename = PointerCast(cx, V_filename, T_ptr(T_i8()));
42934304
let args = [cx.fcx.lltaskptr, V_str, V_filename, C_int(V_line)];
4294-
Call(cx, bcx_ccx(cx).upcalls._fail, args);
4305+
let cx = invoke(cx, bcx_ccx(cx).upcalls._fail, args).bcx;
42954306
Unreachable(cx);
42964307
ret rslt(cx, C_nil());
42974308
}

src/test/run-fail/unwind-fail.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// error-pattern:fail
2+
3+
fn main() {
4+
@0;
5+
fail;
6+
}

0 commit comments

Comments
 (0)