Skip to content

Commit f9c06ab

Browse files
committed
trans: Simplify "try" intrinsic.
1 parent bffb0de commit f9c06ab

File tree

1 file changed

+5
-37
lines changed

1 file changed

+5
-37
lines changed

src/librustc_trans/trans/intrinsic.rs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -350,43 +350,6 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
350350
}
351351
}
352352

353-
// For `try` we need some custom control flow
354-
if &name[..] == "try" {
355-
if let callee::ArgExprs(ref exprs) = args {
356-
let (func, data, local_ptr) = if exprs.len() != 3 {
357-
ccx.sess().bug("expected three exprs as arguments for \
358-
`try` intrinsic");
359-
} else {
360-
(&exprs[0], &exprs[1], &exprs[2])
361-
};
362-
363-
// translate arguments
364-
let func = unpack_datum!(bcx, expr::trans(bcx, func));
365-
let func = unpack_datum!(bcx, func.to_rvalue_datum(bcx, "func"));
366-
let data = unpack_datum!(bcx, expr::trans(bcx, data));
367-
let data = unpack_datum!(bcx, data.to_rvalue_datum(bcx, "data"));
368-
let local_ptr = unpack_datum!(bcx, expr::trans(bcx, local_ptr));
369-
let local_ptr = local_ptr.to_rvalue_datum(bcx, "local_ptr");
370-
let local_ptr = unpack_datum!(bcx, local_ptr);
371-
372-
let dest = match dest {
373-
expr::SaveIn(d) => d,
374-
expr::Ignore => alloc_ty(bcx, tcx.mk_mut_ptr(tcx.types.i8),
375-
"try_result"),
376-
};
377-
378-
// do the invoke
379-
bcx = try_intrinsic(bcx, func.val, data.val, local_ptr.val, dest,
380-
call_debug_location);
381-
382-
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
383-
return Result::new(bcx, dest);
384-
} else {
385-
ccx.sess().bug("expected two exprs as arguments for \
386-
`try` intrinsic");
387-
}
388-
}
389-
390353
// save the actual AST arguments for later (some places need to do
391354
// const-evaluation on them)
392355
let expr_arguments = match args {
@@ -446,6 +409,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
446409
(Some(llfn), _) => {
447410
Call(bcx, llfn, &llargs, call_debug_location)
448411
}
412+
(_, "try") => {
413+
bcx = try_intrinsic(bcx, llargs[0], llargs[1], llargs[2], llresult,
414+
call_debug_location);
415+
C_nil(ccx)
416+
}
449417
(_, "breakpoint") => {
450418
let llfn = ccx.get_intrinsic(&("llvm.debugtrap"));
451419
Call(bcx, llfn, &[], call_debug_location)

0 commit comments

Comments
 (0)