- // Returns a Value of the "eh_unwind_resume" lang item if one is defined,
- // otherwise declares it as an external function.
- fn eh_unwind_resume(&self) -> &'ll Value {
- let unwresume = &self.eh_unwind_resume;
- if let Some(llfn) = unwresume.get() {
- return llfn;
- }
-
- let tcx = self.tcx;
- assert!(self.sess().target.target.options.custom_unwind_resume);
- if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
- let llfn = self.get_fn_addr(
- ty::Instance::resolve(
- tcx,
- ty::ParamEnv::reveal_all(),
- def_id,
- tcx.intern_substs(&[]),
- )
- .unwrap(),
- );
- unwresume.set(Some(llfn));
- return llfn;
- }
-
- let sig = ty::Binder::bind(tcx.mk_fn_sig(
- iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
- tcx.types.never,
- false,
- Unsafety::Unsafe,
- Abi::C,
- ));
-
- let fn_abi = FnAbi::of_fn_ptr(self, sig, &[]);
- let llfn = self.declare_fn("rust_eh_unwind_resume", &fn_abi);
- attributes::apply_target_cpu_attr(self, llfn);
- unwresume.set(Some(llfn));
- llfn
- }
-