|
1 |
| -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT |
| 1 | +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT |
2 | 2 | // file at the top-level directory of this distribution and at
|
3 | 3 | // http://rust-lang.org/COPYRIGHT.
|
4 | 4 | //
|
@@ -639,7 +639,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
639 | 639 | llrustfn: ValueRef,
|
640 | 640 | llwrapfn: ValueRef,
|
641 | 641 | tys: &ForeignTypes<'tcx>,
|
642 |
| - t: Ty<'tcx>, attrs: &[ast::Attribute]) { |
| 642 | + t: Ty<'tcx>, _attrs: &[ast::Attribute]) { |
643 | 643 | let _icx = push_ctxt(
|
644 | 644 | "foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn");
|
645 | 645 | let tcx = ccx.tcx();
|
@@ -816,42 +816,10 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
816 | 816 | // Perform the call itself
|
817 | 817 | debug!("calling llrustfn = {}, t = {}",
|
818 | 818 | ccx.tn().val_to_string(llrustfn), t.repr(ccx.tcx()));
|
| 819 | + // FIXME(aatch) Wrap the call in a try-catch and handle unwinding |
| 820 | + // pending RFC |
819 | 821 | let attributes = base::get_fn_llvm_attributes(ccx, t);
|
820 |
| - let llrust_ret_val = if attr::contains_name(attrs, "can_unwind") { |
821 |
| - debug!("fn can unwind - using call"); |
822 |
| - builder.call(llrustfn, llrust_args.as_slice(), Some(attributes)) |
823 |
| - } else { |
824 |
| - debug!("fn can't unwind - using invoke"); |
825 |
| - // Create the landing pad and the return blocks |
826 |
| - let ptr = "catch\0".as_ptr(); |
827 |
| - let catch_block = llvm::LLVMAppendBasicBlockInContext(ccx.llcx(), llwrapfn, |
828 |
| - ptr as *const _); |
829 |
| - |
830 |
| - let ptr = "return\0".as_ptr(); |
831 |
| - let return_block = llvm::LLVMAppendBasicBlockInContext(ccx.llcx(), llwrapfn, |
832 |
| - ptr as *const _); |
833 |
| - |
834 |
| - |
835 |
| - let llrust_ret_val = builder.invoke(llrustfn, llrust_args.as_slice(), |
836 |
| - return_block, catch_block, |
837 |
| - Some(attributes)); |
838 |
| - |
839 |
| - // Populate the landing pad |
840 |
| - builder.position_at_end(catch_block); |
841 |
| - let pad_ty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)], false); |
842 |
| - let llpersonality = base::get_eh_personality(ccx); |
843 |
| - |
844 |
| - let pad_ret_val = builder.landing_pad(pad_ty, llpersonality, 1us); |
845 |
| - builder.add_clause(pad_ret_val, C_null(Type::i8p(ccx))); |
846 |
| - let trap = ccx.get_intrinsic(&("llvm.trap")); |
847 |
| - builder.call(trap, &[], None); |
848 |
| - builder.unreachable(); |
849 |
| - |
850 |
| - builder.position_at_end(return_block); |
851 |
| - |
852 |
| - llrust_ret_val |
853 |
| - |
854 |
| - }; |
| 822 | + let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), Some(attributes)); |
855 | 823 |
|
856 | 824 | // Get the return value where the foreign fn expects it.
|
857 | 825 | let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
|
|
0 commit comments