Skip to content

Commit

Permalink
Builder.build_new_block -> Builder.build_sibling_block
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jan 4, 2017
1 parent 81e8137 commit 901984e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
14 changes: 2 additions & 12 deletions src/librustc_trans/builder.rs
Expand Up @@ -80,18 +80,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}

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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/callee.rs
Expand Up @@ -370,7 +370,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/cleanup.rs
Expand Up @@ -54,7 +54,7 @@ impl<'tcx> DropValue<'tcx> {
/// 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);

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_trans/glue.rs
Expand Up @@ -263,7 +263,7 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi
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 {
Expand Down Expand Up @@ -503,15 +503,15 @@ fn drop_structural_ty<'a, 'tcx>(cx: Builder<'a, 'tcx>, ptr: LvalueRef<'tcx>) ->
// 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);
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_trans/intrinsic.rs
Expand Up @@ -718,10 +718,10 @@ fn trans_msvc_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,

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);
Expand Down Expand Up @@ -837,8 +837,8 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
// 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);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/mir/mod.rs
Expand Up @@ -218,9 +218,9 @@ pub fn trans_mir<'a, 'tcx: 'a>(
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();

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/tvec.rs
Expand Up @@ -29,9 +29,9 @@ pub fn slice_for_each<'a, 'tcx, F>(
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)
Expand Down

0 comments on commit 901984e

Please sign in to comment.