diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/cleanup.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/common.rs | 33 | ||||
| -rw-r--r-- | src/librustc_trans/context.rs | 40 | ||||
| -rw-r--r-- | src/librustc_trans/mir/block.rs | 6 |
4 files changed, 37 insertions, 44 deletions
diff --git a/src/librustc_trans/cleanup.rs b/src/librustc_trans/cleanup.rs index 84a731c9d7d..9409ac5f8e1 100644 --- a/src/librustc_trans/cleanup.rs +++ b/src/librustc_trans/cleanup.rs @@ -83,7 +83,7 @@ impl<'tcx> DropValue<'tcx> { bcx.resume(llretval); } else { let exc_ptr = bcx.extract_value(llretval, 0); - bcx.call(fcx.eh_unwind_resume().reify(fcx.ccx), &[exc_ptr], None); + bcx.call(bcx.ccx.eh_unwind_resume(), &[exc_ptr], None); bcx.unreachable(); } } diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index ce5a72c7a0f..71e17f1ea74 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -21,10 +21,8 @@ use rustc::hir::def_id::DefId; use rustc::hir::map::DefPathData; use rustc::util::common::MemoizationMap; use middle::lang_items::LangItem; -use abi::Abi; use base; use builder::Builder; -use callee::Callee; use consts; use declare; use machine; @@ -285,37 +283,6 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { BlockAndBuilder::new(self.new_block(name), self) } - // Returns a ValueRef of the "eh_unwind_resume" lang item if one is defined, - // otherwise declares it as an external function. - pub fn eh_unwind_resume(&self) -> Callee<'tcx> { - use attributes; - let ccx = self.ccx; - let tcx = ccx.tcx(); - assert!(ccx.sess().target.target.options.custom_unwind_resume); - if let Some(def_id) = tcx.lang_items.eh_unwind_resume() { - return Callee::def(ccx, def_id, tcx.intern_substs(&[])); - } - - let ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { - unsafety: hir::Unsafety::Unsafe, - abi: Abi::C, - sig: ty::Binder(tcx.mk_fn_sig( - iter::once(tcx.mk_mut_ptr(tcx.types.u8)), - tcx.types.never, - false - )), - })); - - let unwresume = ccx.eh_unwind_resume(); - if let Some(llfn) = unwresume.get() { - return Callee::ptr(llfn, ty); - } - let llfn = declare::declare_fn(ccx, "rust_eh_unwind_resume", ty); - attributes::unwind(llfn, true); - unwresume.set(Some(llfn)); - Callee::ptr(llfn, ty) - } - pub fn alloca(&self, ty: Type, name: &str) -> ValueRef { self.alloca_builder.dynamic_alloca(ty, name) } diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 25a7a5eddd4..0f56aa70bd9 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -12,6 +12,7 @@ use llvm; use llvm::{ContextRef, ModuleRef, ValueRef}; use rustc::dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig, WorkProduct}; use middle::cstore::LinkMeta; +use rustc::hir; use rustc::hir::def::ExportMap; use rustc::hir::def_id::DefId; use rustc::traits; @@ -38,12 +39,13 @@ use std::ffi::{CStr, CString}; use std::cell::{Cell, RefCell}; use std::marker::PhantomData; use std::ptr; +use std::iter; use std::rc::Rc; use std::str; use syntax::ast; use syntax::symbol::InternedString; use syntax_pos::DUMMY_SP; -use abi::FnType; +use abi::{Abi, FnType}; pub struct Stats { pub n_glues_created: Cell<usize>, @@ -827,10 +829,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.local().dbg_cx } - pub fn eh_unwind_resume<'a>(&'a self) -> &'a Cell<Option<ValueRef>> { - &self.local().eh_unwind_resume - } - pub fn rust_try_fn<'a>(&'a self) -> &'a Cell<Option<ValueRef>> { &self.local().rust_try_fn } @@ -951,6 +949,38 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } } + // Returns a ValueRef of the "eh_unwind_resume" lang item if one is defined, + // otherwise declares it as an external function. + pub fn eh_unwind_resume(&self) -> ValueRef { + use attributes; + let unwresume = &self.local().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 = Callee::def(self, def_id, tcx.intern_substs(&[])).reify(self); + unwresume.set(Some(llfn)); + return llfn; + } + + let ty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy { + unsafety: hir::Unsafety::Unsafe, + abi: Abi::C, + sig: ty::Binder(tcx.mk_fn_sig( + iter::once(tcx.mk_mut_ptr(tcx.types.u8)), + tcx.types.never, + false + )), + })); + + let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty); + attributes::unwind(llfn, true); + unwresume.set(Some(llfn)); + llfn + } } pub struct TypeOfDepthLock<'a, 'tcx: 'a>(&'a LocalCrateContext<'tcx>); diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index e665c7a2307..5ad52b3d252 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -125,11 +125,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { bcx.resume(lp); } else { let exc_ptr = bcx.extract_value(lp, 0); - bcx.call( - bcx.fcx().eh_unwind_resume().reify(bcx.ccx), - &[exc_ptr], - cleanup_bundle, - ); + bcx.call(bcx.ccx.eh_unwind_resume(), &[exc_ptr], cleanup_bundle); bcx.unreachable(); } } |
