Change TerminatorKind::Abort to call the panic handler instead of · rust-lang/rust@fe9dc6e (original) (raw)

`@@ -477,6 +477,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

`

477

477

` helper.do_call(self, &mut bx, fn_abi, llfn, &args, None, cleanup);

`

478

478

`}

`

479

479

``

``

480

`+

fn codegen_abort_terminator(

`

``

481

`+

&mut self,

`

``

482

`+

helper: TerminatorCodegenHelper<'tcx>,

`

``

483

`+

mut bx: Bx,

`

``

484

`+

terminator: &mir::Terminator<'tcx>,

`

``

485

`+

) {

`

``

486

`+

let span = terminator.source_info.span;

`

``

487

`+

self.set_debug_loc(&mut bx, terminator.source_info);

`

``

488

+

``

489

`+

// Get the location information.

`

``

490

`+

let location = self.get_caller_location(&mut bx, terminator.source_info).immediate();

`

``

491

+

``

492

`+

// Obtain the panic entry point.

`

``

493

`+

let def_id = common::langcall(bx.tcx(), Some(span), "", LangItem::PanicNoUnwind);

`

``

494

`+

let instance = ty::Instance::mono(bx.tcx(), def_id);

`

``

495

`+

let fn_abi = bx.fn_abi_of_instance(instance, ty::List::empty());

`

``

496

`+

let llfn = bx.get_fn_addr(instance);

`

``

497

+

``

498

`+

// Codegen the actual panic invoke/call.

`

``

499

`+

helper.do_call(self, &mut bx, fn_abi, llfn, &[location], None, None);

`

``

500

`+

}

`

``

501

+

480

502

`` /// Returns true if this is indeed a panic intrinsic and codegen is done.

``

481

503

`fn codegen_panic_intrinsic(

`

482

504

`&mut self,

`

`@@ -1014,10 +1036,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

`

1014

1036

` mir::TerminatorKind::Resume => self.codegen_resume_terminator(helper, bx),

`

1015

1037

``

1016

1038

` mir::TerminatorKind::Abort => {

`

1017

``

`-

bx.abort();

`

1018

``

`` -

// abort does not terminate the block, so we still need to generate

``

1019

``

`` -

// an unreachable terminator after it.

``

1020

``

`-

bx.unreachable();

`

``

1039

`+

self.codegen_abort_terminator(helper, bx, terminator);

`

1021

1040

`}

`

1022

1041

``

1023

1042

` mir::TerminatorKind::Goto { target } => {

`