Skip to content

Commit f706317

Browse files
committed
Support -Cpanic=unwind without unwinding
1 parent 1fb9821 commit f706317

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/builder.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
435435
self.block.end_with_switch(None, value, default_block, &gcc_cases);
436436
}
437437

438-
fn invoke(&mut self, _typ: Type<'gcc>, _func: RValue<'gcc>, _args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
439-
let condition = self.context.new_rvalue_from_int(self.bool_type, 0);
438+
fn invoke(&mut self, typ: Type<'gcc>, func: RValue<'gcc>, args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
439+
// TODO(bjorn3): Properly implement unwinding.
440+
let call_site = self.call(typ, func, args, None);
441+
let condition = self.context.new_rvalue_from_int(self.bool_type, 1);
440442
self.llbb().end_with_conditional(None, condition, then, catch);
441-
self.context.new_rvalue_from_int(self.int_type, 0)
442-
443-
// TODO(antoyo)
443+
call_site
444444
}
445445

446446
fn unreachable(&mut self) {
@@ -1106,7 +1106,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11061106
}
11071107

11081108
fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>) -> RValue<'gcc> {
1109-
let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
1109+
let field1 = self.context.new_field(None, self.u8_type.make_pointer(), "landing_pad_field_1");
11101110
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
11111111
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
11121112
self.current_func().new_local(None, struct_type.as_type(), "landing_pad")
@@ -1117,7 +1117,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11171117
}
11181118

11191119
fn resume(&mut self, _exn: RValue<'gcc>) {
1120-
unimplemented!();
1120+
// TODO(bjorn3): Properly implement unwinding.
1121+
self.unreachable();
11211122
}
11221123

11231124
fn cleanup_pad(&mut self, _parent: Option<RValue<'gcc>>, _args: &[RValue<'gcc>]) -> Funclet {

src/intrinsic/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
10861086
}
10871087

10881088
fn try_intrinsic<'gcc, 'tcx>(bx: &mut Builder<'_, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, _catch_func: RValue<'gcc>, dest: RValue<'gcc>) {
1089-
if bx.sess().panic_strategy() == PanicStrategy::Abort {
1089+
// NOTE: the `|| true` here is to use the panic=abort strategy with panic=unwind too
1090+
if bx.sess().panic_strategy() == PanicStrategy::Abort || true {
1091+
// TODO(bjorn3): Properly implement unwinding and remove the `|| true` once this is done.
10901092
bx.call(bx.type_void(), try_func, &[data], None);
10911093
// Return 0 unconditionally from the intrinsic call;
10921094
// we can never unwind.

0 commit comments

Comments
 (0)