2015-10-21 16:42:25 -05:00
|
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
2016-01-01 16:45:21 -06:00
|
|
|
|
use llvm::{BasicBlockRef, ValueRef};
|
2016-01-12 07:20:18 -06:00
|
|
|
|
use rustc::middle::ty;
|
2015-11-19 09:37:34 -06:00
|
|
|
|
use rustc::mir::repr as mir;
|
2016-01-12 07:20:18 -06:00
|
|
|
|
use syntax::abi::Abi;
|
2015-12-11 12:19:19 -06:00
|
|
|
|
use trans::adt;
|
2016-01-12 07:20:18 -06:00
|
|
|
|
use trans::attributes;
|
2015-10-21 16:42:25 -05:00
|
|
|
|
use trans::base;
|
|
|
|
|
use trans::build;
|
2016-02-08 16:08:47 -06:00
|
|
|
|
use trans::common::{self, Block, BlockAndBuilder};
|
2015-10-21 16:42:25 -05:00
|
|
|
|
use trans::debuginfo::DebugLoc;
|
2016-01-29 16:18:47 -06:00
|
|
|
|
use trans::Disr;
|
2016-01-12 07:20:18 -06:00
|
|
|
|
use trans::foreign;
|
2016-01-29 16:18:47 -06:00
|
|
|
|
use trans::glue;
|
2015-12-13 07:48:43 -06:00
|
|
|
|
use trans::type_of;
|
2015-12-19 08:47:52 -06:00
|
|
|
|
use trans::type_::Type;
|
2015-10-21 16:42:25 -05:00
|
|
|
|
|
|
|
|
|
use super::MirContext;
|
2015-12-13 07:48:43 -06:00
|
|
|
|
use super::operand::OperandValue::{FatPtr, Immediate, Ref};
|
2015-10-21 16:42:25 -05:00
|
|
|
|
|
|
|
|
|
impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|
|
|
|
pub fn trans_block(&mut self, bb: mir::BasicBlock) {
|
|
|
|
|
debug!("trans_block({:?})", bb);
|
|
|
|
|
|
|
|
|
|
let mut bcx = self.bcx(bb);
|
|
|
|
|
let data = self.mir.basic_block_data(bb);
|
|
|
|
|
|
|
|
|
|
for statement in &data.statements {
|
|
|
|
|
bcx = self.trans_statement(bcx, statement);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:44:32 -06:00
|
|
|
|
debug!("trans_block: terminator: {:?}", data.terminator());
|
2015-10-21 16:42:25 -05:00
|
|
|
|
|
2015-12-18 16:44:32 -06:00
|
|
|
|
match *data.terminator() {
|
2015-10-21 16:42:25 -05:00
|
|
|
|
mir::Terminator::Goto { target } => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.br(self.llblock(target));
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-10 14:46:40 -06:00
|
|
|
|
mir::Terminator::If { ref cond, targets: (true_bb, false_bb) } => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let cond = self.trans_operand(&bcx, cond);
|
2015-10-21 16:42:25 -05:00
|
|
|
|
let lltrue = self.llblock(true_bb);
|
|
|
|
|
let llfalse = self.llblock(false_bb);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.cond_br(cond.immediate(), lltrue, llfalse);
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 12:19:19 -06:00
|
|
|
|
mir::Terminator::Switch { ref discr, ref adt_def, ref targets } => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let discr_lvalue = self.trans_lvalue(&bcx, discr);
|
2016-01-13 19:22:02 -06:00
|
|
|
|
let ty = discr_lvalue.ty.to_ty(bcx.tcx());
|
|
|
|
|
let repr = adt::represent_type(bcx.ccx(), ty);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let discr = bcx.with_block(|bcx|
|
|
|
|
|
adt::trans_get_discr(bcx, &repr, discr_lvalue.llval, None, true)
|
|
|
|
|
);
|
2015-12-11 12:19:19 -06:00
|
|
|
|
|
|
|
|
|
// The else branch of the Switch can't be hit, so branch to an unreachable
|
|
|
|
|
// instruction so LLVM knows that
|
2015-12-19 08:47:52 -06:00
|
|
|
|
let unreachable_blk = self.unreachable_block();
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let switch = bcx.switch(discr, unreachable_blk.llbb, targets.len());
|
2015-12-11 12:19:19 -06:00
|
|
|
|
assert_eq!(adt_def.variants.len(), targets.len());
|
|
|
|
|
for (adt_variant, target) in adt_def.variants.iter().zip(targets) {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let llval = bcx.with_block(|bcx|
|
|
|
|
|
adt::trans_case(bcx, &*repr, Disr::from(adt_variant.disr_val))
|
|
|
|
|
);
|
2015-12-11 12:19:19 -06:00
|
|
|
|
let llbb = self.llblock(*target);
|
|
|
|
|
build::AddCase(switch, llval, llbb)
|
|
|
|
|
}
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-08 12:11:11 -06:00
|
|
|
|
mir::Terminator::SwitchInt { ref discr, switch_ty, ref values, ref targets } => {
|
|
|
|
|
let (otherwise, targets) = targets.split_last().unwrap();
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let discr = bcx.load(self.trans_lvalue(&bcx, discr).llval);
|
|
|
|
|
let switch = bcx.switch(discr, self.llblock(*otherwise), values.len());
|
2015-11-08 12:11:11 -06:00
|
|
|
|
for (value, target) in values.iter().zip(targets) {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let llval = self.trans_constval(&bcx, value, switch_ty).immediate();
|
2015-11-08 12:11:11 -06:00
|
|
|
|
let llbb = self.llblock(*target);
|
|
|
|
|
build::AddCase(switch, llval, llbb)
|
|
|
|
|
}
|
2015-10-26 13:35:18 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-15 12:46:39 -06:00
|
|
|
|
mir::Terminator::Resume => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let ps = self.get_personality_slot(&bcx);
|
|
|
|
|
let lp = bcx.load(ps);
|
|
|
|
|
bcx.with_block(|bcx| {
|
|
|
|
|
base::call_lifetime_end(bcx, ps);
|
|
|
|
|
base::trans_unwind_resume(bcx, lp);
|
|
|
|
|
});
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mir::Terminator::Return => {
|
|
|
|
|
let return_ty = bcx.monomorphize(&self.mir.return_ty);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.with_block(|bcx| {
|
|
|
|
|
base::build_return_block(bcx.fcx, bcx, return_ty, DebugLoc::None);
|
|
|
|
|
})
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 11:32:50 -06:00
|
|
|
|
mir::Terminator::Drop { ref value, target, unwind } => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let lvalue = self.trans_lvalue(&bcx, value);
|
2016-01-30 11:32:50 -06:00
|
|
|
|
let ty = lvalue.ty.to_ty(bcx.tcx());
|
|
|
|
|
// Double check for necessity to drop
|
|
|
|
|
if !glue::type_needs_drop(bcx.tcx(), ty) {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.br(self.llblock(target));
|
2016-01-30 11:32:50 -06:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let drop_fn = glue::get_drop_glue(bcx.ccx(), ty);
|
|
|
|
|
let drop_ty = glue::get_drop_glue_type(bcx.ccx(), ty);
|
|
|
|
|
let llvalue = if drop_ty != ty {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.pointercast(lvalue.llval, type_of::type_of(bcx.ccx(), drop_ty).ptr_to())
|
2016-01-30 11:32:50 -06:00
|
|
|
|
} else {
|
|
|
|
|
lvalue.llval
|
|
|
|
|
};
|
|
|
|
|
if let Some(unwind) = unwind {
|
|
|
|
|
let uwbcx = self.bcx(unwind);
|
|
|
|
|
let unwind = self.make_landing_pad(uwbcx);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.invoke(drop_fn,
|
|
|
|
|
&[llvalue],
|
|
|
|
|
self.llblock(target),
|
|
|
|
|
unwind.llbb(),
|
2016-02-08 16:08:47 -06:00
|
|
|
|
None,
|
2016-02-01 04:04:46 -06:00
|
|
|
|
None);
|
2016-01-30 11:32:50 -06:00
|
|
|
|
} else {
|
2016-02-08 16:08:47 -06:00
|
|
|
|
bcx.call(drop_fn, &[llvalue], None, None);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.br(self.llblock(target));
|
2016-01-30 11:32:50 -06:00
|
|
|
|
}
|
2016-01-29 16:18:47 -06:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-29 12:42:02 -06:00
|
|
|
|
mir::Terminator::Call { ref func, ref args, ref destination, ref cleanup } => {
|
2015-12-21 17:46:56 -06:00
|
|
|
|
// Create the callee. This will always be a fn ptr and hence a kind of scalar.
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let callee = self.trans_operand(&bcx, func);
|
2015-12-21 17:46:56 -06:00
|
|
|
|
let attrs = attributes::from_fn_type(bcx.ccx(), callee.ty);
|
|
|
|
|
let debugloc = DebugLoc::None;
|
|
|
|
|
// The arguments we'll be passing. Plus one to account for outptr, if used.
|
|
|
|
|
let mut llargs = Vec::with_capacity(args.len() + 1);
|
2016-01-12 07:20:18 -06:00
|
|
|
|
// Types of the arguments. We do not preallocate, because this vector is only
|
|
|
|
|
// filled when `is_foreign` is `true` and foreign calls are minority of the cases.
|
|
|
|
|
let mut arg_tys = Vec::new();
|
|
|
|
|
|
|
|
|
|
// Foreign-ABI functions are translated differently
|
|
|
|
|
let is_foreign = if let ty::TyBareFn(_, ref f) = callee.ty.sty {
|
|
|
|
|
// We do not translate intrinsics here (they shouldn’t be functions)
|
|
|
|
|
assert!(f.abi != Abi::RustIntrinsic && f.abi != Abi::PlatformIntrinsic);
|
|
|
|
|
f.abi != Abi::Rust && f.abi != Abi::RustCall
|
|
|
|
|
} else {
|
|
|
|
|
false
|
|
|
|
|
};
|
2015-12-21 17:46:56 -06:00
|
|
|
|
|
|
|
|
|
// Prepare the return value destination
|
2016-01-29 12:42:02 -06:00
|
|
|
|
let (ret_dest_ty, must_copy_dest) = if let Some((ref d, _)) = *destination {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let dest = self.trans_lvalue(&bcx, d);
|
2015-12-21 17:46:56 -06:00
|
|
|
|
let ret_ty = dest.ty.to_ty(bcx.tcx());
|
2016-01-12 07:20:18 -06:00
|
|
|
|
if !is_foreign && type_of::return_uses_outptr(bcx.ccx(), ret_ty) {
|
2015-12-21 17:46:56 -06:00
|
|
|
|
llargs.push(dest.llval);
|
|
|
|
|
(Some((dest, ret_ty)), false)
|
|
|
|
|
} else {
|
|
|
|
|
(Some((dest, ret_ty)), !common::type_is_zero_size(bcx.ccx(), ret_ty))
|
|
|
|
|
}
|
2015-12-13 07:48:43 -06:00
|
|
|
|
} else {
|
2015-12-21 17:46:56 -06:00
|
|
|
|
(None, false)
|
2015-12-13 07:48:43 -06:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Process the rest of the args.
|
2015-12-19 08:48:49 -06:00
|
|
|
|
for arg in args {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let operand = self.trans_operand(&bcx, arg);
|
2016-01-12 07:20:18 -06:00
|
|
|
|
match operand.val {
|
2015-12-13 07:48:43 -06:00
|
|
|
|
Ref(llval) | Immediate(llval) => llargs.push(llval),
|
2015-12-21 17:46:56 -06:00
|
|
|
|
FatPtr(b, e) => {
|
|
|
|
|
llargs.push(b);
|
|
|
|
|
llargs.push(e);
|
2015-12-13 07:48:43 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-12 07:20:18 -06:00
|
|
|
|
if is_foreign {
|
|
|
|
|
arg_tys.push(operand.ty);
|
|
|
|
|
}
|
2015-12-13 07:48:43 -06:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 17:46:56 -06:00
|
|
|
|
// Many different ways to call a function handled here
|
2016-02-11 02:13:35 -06:00
|
|
|
|
match (is_foreign, cleanup, destination) {
|
2015-12-21 17:46:56 -06:00
|
|
|
|
// The two cases below are the only ones to use LLVM’s `invoke`.
|
2016-02-11 02:13:35 -06:00
|
|
|
|
(false, &Some(cleanup), &None) => {
|
2015-12-20 07:30:09 -06:00
|
|
|
|
let cleanup = self.bcx(cleanup);
|
2015-12-19 08:48:49 -06:00
|
|
|
|
let landingpad = self.make_landing_pad(cleanup);
|
2016-01-12 07:20:18 -06:00
|
|
|
|
let unreachable_blk = self.unreachable_block();
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.invoke(callee.immediate(),
|
|
|
|
|
&llargs[..],
|
|
|
|
|
unreachable_blk.llbb,
|
|
|
|
|
landingpad.llbb(),
|
2016-02-08 16:08:47 -06:00
|
|
|
|
None,
|
2016-02-01 04:04:46 -06:00
|
|
|
|
Some(attrs));
|
2015-12-21 17:46:56 -06:00
|
|
|
|
},
|
2016-02-11 02:13:35 -06:00
|
|
|
|
(false, &Some(cleanup), &Some((_, success))) => {
|
2016-01-29 12:42:02 -06:00
|
|
|
|
let cleanup = self.bcx(cleanup);
|
2015-12-21 17:46:56 -06:00
|
|
|
|
let landingpad = self.make_landing_pad(cleanup);
|
|
|
|
|
let (target, postinvoke) = if must_copy_dest {
|
2016-02-08 16:08:47 -06:00
|
|
|
|
(bcx.fcx().new_block("", None).build(), Some(self.bcx(success)))
|
2015-12-21 17:46:56 -06:00
|
|
|
|
} else {
|
2016-01-29 12:42:02 -06:00
|
|
|
|
(self.bcx(success), None)
|
2015-12-21 17:46:56 -06:00
|
|
|
|
};
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let invokeret = bcx.invoke(callee.immediate(),
|
|
|
|
|
&llargs[..],
|
|
|
|
|
target.llbb(),
|
|
|
|
|
landingpad.llbb(),
|
2016-02-08 16:08:47 -06:00
|
|
|
|
None,
|
2016-02-01 04:04:46 -06:00
|
|
|
|
Some(attrs));
|
2015-12-21 17:46:56 -06:00
|
|
|
|
if let Some(postinvoketarget) = postinvoke {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
// We translate the copy into a temporary block. The temporary block is
|
2015-12-21 17:46:56 -06:00
|
|
|
|
// necessary because the current block has already been terminated (by
|
|
|
|
|
// `invoke`) and we cannot really translate into the target block
|
|
|
|
|
// because:
|
|
|
|
|
// * The target block may have more than a single precedesor;
|
|
|
|
|
// * Some LLVM insns cannot have a preceeding store insn (phi,
|
|
|
|
|
// cleanuppad), and adding/prepending the store now may render
|
|
|
|
|
// those other instructions invalid.
|
|
|
|
|
//
|
|
|
|
|
// NB: This approach still may break some LLVM code. For example if the
|
|
|
|
|
// target block starts with a `phi` (which may only match on immediate
|
|
|
|
|
// precedesors), it cannot know about this temporary block thus
|
|
|
|
|
// resulting in an invalid code:
|
|
|
|
|
//
|
|
|
|
|
// this:
|
|
|
|
|
// …
|
|
|
|
|
// %0 = …
|
|
|
|
|
// %1 = invoke to label %temp …
|
|
|
|
|
// temp:
|
|
|
|
|
// store ty %1, ty* %dest
|
|
|
|
|
// br label %actualtargetblock
|
|
|
|
|
// actualtargetblock: ; preds: %temp, …
|
|
|
|
|
// phi … [%this, …], [%0, …] ; ERROR: phi requires to match only on
|
|
|
|
|
// ; immediate precedesors
|
|
|
|
|
let (ret_dest, ret_ty) = ret_dest_ty
|
|
|
|
|
.expect("return destination and type not set");
|
2016-02-01 04:04:46 -06:00
|
|
|
|
target.with_block(|target| {
|
|
|
|
|
base::store_ty(target, invokeret, ret_dest.llval, ret_ty);
|
|
|
|
|
});
|
|
|
|
|
target.br(postinvoketarget.llbb());
|
2015-12-19 08:48:49 -06:00
|
|
|
|
}
|
2015-12-20 07:30:09 -06:00
|
|
|
|
},
|
2016-02-11 02:13:35 -06:00
|
|
|
|
(false, _, &None) => {
|
2016-02-08 16:08:47 -06:00
|
|
|
|
bcx.call(callee.immediate(), &llargs[..], None, Some(attrs));
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.unreachable();
|
2015-12-21 17:46:56 -06:00
|
|
|
|
}
|
2016-02-11 02:13:35 -06:00
|
|
|
|
(false, _, &Some((_, target))) => {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
let llret = bcx.call(callee.immediate(),
|
|
|
|
|
&llargs[..],
|
2016-02-08 16:08:47 -06:00
|
|
|
|
None,
|
2016-02-01 04:04:46 -06:00
|
|
|
|
Some(attrs));
|
2015-12-21 17:46:56 -06:00
|
|
|
|
if must_copy_dest {
|
|
|
|
|
let (ret_dest, ret_ty) = ret_dest_ty
|
|
|
|
|
.expect("return destination and type not set");
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.with_block(|bcx| {
|
|
|
|
|
base::store_ty(bcx, llret, ret_dest.llval, ret_ty);
|
|
|
|
|
});
|
2015-12-20 07:30:09 -06:00
|
|
|
|
}
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.br(self.llblock(target));
|
2015-12-13 07:48:43 -06:00
|
|
|
|
}
|
2016-01-12 07:20:18 -06:00
|
|
|
|
// Foreign functions
|
2016-02-11 02:13:35 -06:00
|
|
|
|
(true, _, destination) => {
|
2016-01-12 07:20:18 -06:00
|
|
|
|
let (dest, _) = ret_dest_ty
|
|
|
|
|
.expect("return destination is not set");
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx = bcx.map_block(|bcx| {
|
|
|
|
|
foreign::trans_native_call(bcx,
|
|
|
|
|
callee.ty,
|
|
|
|
|
callee.immediate(),
|
|
|
|
|
dest.llval,
|
|
|
|
|
&llargs[..],
|
|
|
|
|
arg_tys,
|
|
|
|
|
debugloc)
|
|
|
|
|
});
|
2016-01-29 12:42:02 -06:00
|
|
|
|
if let Some((_, target)) = *destination {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.br(self.llblock(target));
|
2016-01-29 12:42:02 -06:00
|
|
|
|
}
|
2016-01-12 07:20:18 -06:00
|
|
|
|
},
|
2015-12-13 07:48:43 -06:00
|
|
|
|
}
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 04:04:46 -06:00
|
|
|
|
fn get_personality_slot(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>) -> ValueRef {
|
2016-01-01 16:45:21 -06:00
|
|
|
|
let ccx = bcx.ccx();
|
|
|
|
|
if let Some(slot) = self.llpersonalityslot {
|
|
|
|
|
slot
|
|
|
|
|
} else {
|
|
|
|
|
let llretty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)], false);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.with_block(|bcx| {
|
2016-02-08 16:08:47 -06:00
|
|
|
|
let slot = base::alloca(bcx, llretty, "personalityslot");
|
|
|
|
|
self.llpersonalityslot = Some(slot);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
base::call_lifetime_start(bcx, slot);
|
2016-02-08 16:08:47 -06:00
|
|
|
|
slot
|
|
|
|
|
})
|
2016-01-01 16:45:21 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 04:04:46 -06:00
|
|
|
|
fn make_landing_pad(&mut self,
|
|
|
|
|
cleanup: BlockAndBuilder<'bcx, 'tcx>)
|
|
|
|
|
-> BlockAndBuilder<'bcx, 'tcx>
|
|
|
|
|
{
|
2016-02-08 16:08:47 -06:00
|
|
|
|
// FIXME(#30941) this doesn't handle msvc-style exceptions
|
|
|
|
|
let bcx = self.fcx.new_block("cleanup", None).build();
|
2015-12-19 08:48:49 -06:00
|
|
|
|
let ccx = bcx.ccx();
|
2016-02-08 16:08:47 -06:00
|
|
|
|
let llpersonality = self.fcx.eh_personality();
|
2015-12-19 08:48:49 -06:00
|
|
|
|
let llretty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)], false);
|
2016-02-08 16:08:47 -06:00
|
|
|
|
let llretval = bcx.landing_pad(llretty, llpersonality, 1, self.fcx.llfn);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bcx.set_cleanup(llretval);
|
|
|
|
|
let slot = self.get_personality_slot(&bcx);
|
|
|
|
|
bcx.store(llretval, slot);
|
2016-02-08 16:08:47 -06:00
|
|
|
|
bcx.br(cleanup.llbb());
|
2015-12-19 08:48:49 -06:00
|
|
|
|
bcx
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-19 08:47:52 -06:00
|
|
|
|
fn unreachable_block(&mut self) -> Block<'bcx, 'tcx> {
|
2016-02-01 04:04:46 -06:00
|
|
|
|
self.unreachable_block.unwrap_or_else(|| {
|
2016-02-08 16:08:47 -06:00
|
|
|
|
let bl = self.fcx.new_block("unreachable", None);
|
2016-02-01 04:04:46 -06:00
|
|
|
|
bl.build().unreachable();
|
|
|
|
|
self.unreachable_block = Some(bl);
|
|
|
|
|
bl
|
|
|
|
|
})
|
2015-12-19 08:47:52 -06:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 04:04:46 -06:00
|
|
|
|
fn bcx(&self, bb: mir::BasicBlock) -> BlockAndBuilder<'bcx, 'tcx> {
|
|
|
|
|
self.blocks[bb.index()].build()
|
2015-10-21 16:42:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn llblock(&self, bb: mir::BasicBlock) -> BasicBlockRef {
|
|
|
|
|
self.blocks[bb.index()].llbb
|
|
|
|
|
}
|
|
|
|
|
}
|