Skip to content

Commit a291dd0

Browse files
committed
Stop needing an alloca for catch_unwind
Turns out these were all making `OperandValue::Immediate`s already -- the intrinsic always returns a primitive scalar -- so pretty easy to handle. While I was looking at it, I also "rustified" the intrinsic signature a bit: returning a `bool` and taking a generic pointee and `unsafe fn`s cleans up the call in `std` a bit without making the implementation in the backend any harder.
1 parent 5e72aee commit a291dd0

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/intrinsic/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(
13611361
bx.call(bx.type_void(), None, None, try_func, &[data], None, None);
13621362
// Return 0 unconditionally from the intrinsic call;
13631363
// we can never unwind.
1364-
OperandValue::Immediate(bx.const_i32(0)).store(bx, dest);
1364+
OperandValue::Immediate(bx.const_bool(false)).store(bx, dest);
13651365
} else {
13661366
if wants_msvc_seh(bx.sess()) {
13671367
unimplemented!();
@@ -1418,7 +1418,7 @@ fn codegen_gnu_try<'gcc, 'tcx>(
14181418
let current_block = bx.block;
14191419

14201420
bx.switch_to_block(then);
1421-
bx.ret(bx.const_i32(0));
1421+
bx.ret(bx.const_bool(false));
14221422

14231423
// Type indicator for the exception being thrown.
14241424
//
@@ -1432,7 +1432,7 @@ fn codegen_gnu_try<'gcc, 'tcx>(
14321432
let ptr = bx.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
14331433
let catch_ty = bx.type_func(&[bx.type_i8p(), bx.type_i8p()], bx.type_void());
14341434
bx.call(catch_ty, None, None, catch_func, &[data, ptr], None, None);
1435-
bx.ret(bx.const_i32(1));
1435+
bx.ret(bx.const_bool(true));
14361436

14371437
// NOTE: the blocks must be filled before adding the try/catch, otherwise gcc will not
14381438
// generate a try/catch.
@@ -1465,7 +1465,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
14651465
// Define the type up front for the signature of the rust_try function.
14661466
let tcx = cx.tcx;
14671467
let i8p = Ty::new_mut_ptr(tcx, tcx.types.i8);
1468-
// `unsafe fn(*mut i8) -> ()`
1468+
// `unsafe fn(*mut Data) -> ()`
14691469
let try_fn_ty = Ty::new_fn_ptr(
14701470
tcx,
14711471
ty::Binder::dummy(tcx.mk_fn_sig_rust_abi(
@@ -1474,7 +1474,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
14741474
rustc_hir::Safety::Unsafe,
14751475
)),
14761476
);
1477-
// `unsafe fn(*mut i8, *mut i8) -> ()`
1477+
// `unsafe fn(*mut Data, *mut i8) -> ()`
14781478
let catch_fn_ty = Ty::new_fn_ptr(
14791479
tcx,
14801480
ty::Binder::dummy(tcx.mk_fn_sig_rust_abi(
@@ -1483,10 +1483,10 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
14831483
rustc_hir::Safety::Unsafe,
14841484
)),
14851485
);
1486-
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
1486+
// `unsafe fn(unsafe fn(*mut Data) -> (), *mut Data, unsafe fn(*mut Data, *mut i8) -> ()) -> bool`
14871487
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig_rust_abi(
14881488
[try_fn_ty, i8p, catch_fn_ty],
1489-
tcx.types.i32,
1489+
tcx.types.bool,
14901490
rustc_hir::Safety::Unsafe,
14911491
));
14921492
let rust_try = gen_fn(cx, "__rust_try", rust_fn_sig, codegen);

0 commit comments

Comments
 (0)