}
}
- pub fn build_new_block<'b>(&self, name: &'b str) -> Builder<'a, 'tcx> {
- let builder = Builder::with_ccx(self.ccx);
- let llbb = unsafe {
- let name = CString::new(name).unwrap();
- llvm::LLVMAppendBasicBlockInContext(
- self.ccx.llcx(),
- self.llfn(),
- name.as_ptr()
- )
- };
- builder.position_at_end(llbb);
- builder
+ pub fn build_sibling_block<'b>(&self, name: &'b str) -> Builder<'a, 'tcx> {
+ Builder::new_block(self.ccx, self.llfn(), name)
}
pub fn sess(&self) -> &Session {
let llfn = callee.reify(bcx.ccx);
let llret;
if let Some(landing_pad) = self_scope.landing_pad {
- let normal_bcx = bcx.build_new_block("normal-return");
+ let normal_bcx = bcx.build_sibling_block("normal-return");
llret = bcx.invoke(llfn, &llargs[..], normal_bcx.llbb(), landing_pad, None);
bcx = normal_bcx;
} else {
/// This should only be called once per function, as it creates an alloca for the landingpad.
fn get_landing_pad<'a>(&self, bcx: &Builder<'a, 'tcx>) -> BasicBlockRef {
debug!("get_landing_pad");
- let bcx = bcx.build_new_block("cleanup_unwind");
+ let bcx = bcx.build_sibling_block("cleanup_unwind");
let llpersonality = bcx.ccx.eh_personality();
bcx.set_personality_fn(llpersonality);
let llret;
let args = &[ptr.llval, ptr.llextra][..1 + ptr.has_extra() as usize];
if let Some(landing_pad) = contents_scope.landing_pad {
- let normal_bcx = bcx.build_new_block("normal-return");
+ let normal_bcx = bcx.build_sibling_block("normal-return");
llret = bcx.invoke(callee.reify(ccx), args, normal_bcx.llbb(), landing_pad, None);
bcx = normal_bcx;
} else {
// from the outer function, and any other use case will only
// call this for an already-valid enum in which case the `ret
// void` will never be hit.
- let ret_void_cx = cx.build_new_block("enum-iter-ret-void");
+ let ret_void_cx = cx.build_sibling_block("enum-iter-ret-void");
ret_void_cx.ret_void();
let llswitch = cx.switch(lldiscrim_a, ret_void_cx.llbb(), n_variants);
- let next_cx = cx.build_new_block("enum-iter-next");
+ let next_cx = cx.build_sibling_block("enum-iter-next");
for (i, variant) in adt.variants.iter().enumerate() {
let variant_cx_name = format!("enum-iter-variant-{}",
&variant.disr_val.to_string());
- let variant_cx = cx.build_new_block(&variant_cx_name);
+ let variant_cx = cx.build_sibling_block(&variant_cx_name);
let case_val = adt::trans_case(&cx, t, Disr::from(variant.disr_val));
variant_cx.add_case(llswitch, case_val, variant_cx.llbb());
iter_variant(&variant_cx, ptr, &adt, i, substs);
bcx.set_personality_fn(bcx.ccx.eh_personality());
- let normal = bcx.build_new_block("normal");
- let catchswitch = bcx.build_new_block("catchswitch");
- let catchpad = bcx.build_new_block("catchpad");
- let caught = bcx.build_new_block("caught");
+ let normal = bcx.build_sibling_block("normal");
+ let catchswitch = bcx.build_sibling_block("catchswitch");
+ let catchpad = bcx.build_sibling_block("catchpad");
+ let caught = bcx.build_sibling_block("caught");
let func = llvm::get_param(bcx.llfn(), 0);
let data = llvm::get_param(bcx.llfn(), 1);
// expected to be `*mut *mut u8` for this to actually work, but that's
// managed by the standard library.
- let then = bcx.build_new_block("then");
- let catch = bcx.build_new_block("catch");
+ let then = bcx.build_sibling_block("then");
+ let catch = bcx.build_sibling_block("catch");
let func = llvm::get_param(bcx.llfn(), 0);
let data = llvm::get_param(bcx.llfn(), 1);
let block_bcxs: IndexVec<mir::BasicBlock, BasicBlockRef> =
mir.basic_blocks().indices().map(|bb| {
if bb == mir::START_BLOCK {
- bcx.build_new_block("start").llbb()
+ bcx.build_sibling_block("start").llbb()
} else {
- bcx.build_new_block(&format!("{:?}", bb)).llbb()
+ bcx.build_sibling_block(&format!("{:?}", bb)).llbb()
}
}).collect();
bcx.inbounds_gep(a, &[b])
};
- let body_bcx = bcx.build_new_block("slice_loop_body");
- let next_bcx = bcx.build_new_block("slice_loop_next");
- let header_bcx = bcx.build_new_block("slice_loop_header");
+ let body_bcx = bcx.build_sibling_block("slice_loop_body");
+ let next_bcx = bcx.build_sibling_block("slice_loop_next");
+ let header_bcx = bcx.build_sibling_block("slice_loop_header");
let start = if zst {
C_uint(bcx.ccx, 0usize)