Skip to content

Commit 901984e

Browse files
Builder.build_new_block -> Builder.build_sibling_block
1 parent 81e8137 commit 901984e

File tree

7 files changed

+19
-29
lines changed

7 files changed

+19
-29
lines changed

src/librustc_trans/builder.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8080
}
8181
}
8282

83-
pub fn build_new_block<'b>(&self, name: &'b str) -> Builder<'a, 'tcx> {
84-
let builder = Builder::with_ccx(self.ccx);
85-
let llbb = unsafe {
86-
let name = CString::new(name).unwrap();
87-
llvm::LLVMAppendBasicBlockInContext(
88-
self.ccx.llcx(),
89-
self.llfn(),
90-
name.as_ptr()
91-
)
92-
};
93-
builder.position_at_end(llbb);
94-
builder
83+
pub fn build_sibling_block<'b>(&self, name: &'b str) -> Builder<'a, 'tcx> {
84+
Builder::new_block(self.ccx, self.llfn(), name)
9585
}
9686

9787
pub fn sess(&self) -> &Session {

src/librustc_trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
370370
let llfn = callee.reify(bcx.ccx);
371371
let llret;
372372
if let Some(landing_pad) = self_scope.landing_pad {
373-
let normal_bcx = bcx.build_new_block("normal-return");
373+
let normal_bcx = bcx.build_sibling_block("normal-return");
374374
llret = bcx.invoke(llfn, &llargs[..], normal_bcx.llbb(), landing_pad, None);
375375
bcx = normal_bcx;
376376
} else {

src/librustc_trans/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> DropValue<'tcx> {
5454
/// This should only be called once per function, as it creates an alloca for the landingpad.
5555
fn get_landing_pad<'a>(&self, bcx: &Builder<'a, 'tcx>) -> BasicBlockRef {
5656
debug!("get_landing_pad");
57-
let bcx = bcx.build_new_block("cleanup_unwind");
57+
let bcx = bcx.build_sibling_block("cleanup_unwind");
5858
let llpersonality = bcx.ccx.eh_personality();
5959
bcx.set_personality_fn(llpersonality);
6060

src/librustc_trans/glue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi
263263
let llret;
264264
let args = &[ptr.llval, ptr.llextra][..1 + ptr.has_extra() as usize];
265265
if let Some(landing_pad) = contents_scope.landing_pad {
266-
let normal_bcx = bcx.build_new_block("normal-return");
266+
let normal_bcx = bcx.build_sibling_block("normal-return");
267267
llret = bcx.invoke(callee.reify(ccx), args, normal_bcx.llbb(), landing_pad, None);
268268
bcx = normal_bcx;
269269
} else {
@@ -503,15 +503,15 @@ fn drop_structural_ty<'a, 'tcx>(cx: Builder<'a, 'tcx>, ptr: LvalueRef<'tcx>) ->
503503
// from the outer function, and any other use case will only
504504
// call this for an already-valid enum in which case the `ret
505505
// void` will never be hit.
506-
let ret_void_cx = cx.build_new_block("enum-iter-ret-void");
506+
let ret_void_cx = cx.build_sibling_block("enum-iter-ret-void");
507507
ret_void_cx.ret_void();
508508
let llswitch = cx.switch(lldiscrim_a, ret_void_cx.llbb(), n_variants);
509-
let next_cx = cx.build_new_block("enum-iter-next");
509+
let next_cx = cx.build_sibling_block("enum-iter-next");
510510

511511
for (i, variant) in adt.variants.iter().enumerate() {
512512
let variant_cx_name = format!("enum-iter-variant-{}",
513513
&variant.disr_val.to_string());
514-
let variant_cx = cx.build_new_block(&variant_cx_name);
514+
let variant_cx = cx.build_sibling_block(&variant_cx_name);
515515
let case_val = adt::trans_case(&cx, t, Disr::from(variant.disr_val));
516516
variant_cx.add_case(llswitch, case_val, variant_cx.llbb());
517517
iter_variant(&variant_cx, ptr, &adt, i, substs);

src/librustc_trans/intrinsic.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,10 @@ fn trans_msvc_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
718718

719719
bcx.set_personality_fn(bcx.ccx.eh_personality());
720720

721-
let normal = bcx.build_new_block("normal");
722-
let catchswitch = bcx.build_new_block("catchswitch");
723-
let catchpad = bcx.build_new_block("catchpad");
724-
let caught = bcx.build_new_block("caught");
721+
let normal = bcx.build_sibling_block("normal");
722+
let catchswitch = bcx.build_sibling_block("catchswitch");
723+
let catchpad = bcx.build_sibling_block("catchpad");
724+
let caught = bcx.build_sibling_block("caught");
725725

726726
let func = llvm::get_param(bcx.llfn(), 0);
727727
let data = llvm::get_param(bcx.llfn(), 1);
@@ -837,8 +837,8 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
837837
// expected to be `*mut *mut u8` for this to actually work, but that's
838838
// managed by the standard library.
839839

840-
let then = bcx.build_new_block("then");
841-
let catch = bcx.build_new_block("catch");
840+
let then = bcx.build_sibling_block("then");
841+
let catch = bcx.build_sibling_block("catch");
842842

843843
let func = llvm::get_param(bcx.llfn(), 0);
844844
let data = llvm::get_param(bcx.llfn(), 1);

src/librustc_trans/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ pub fn trans_mir<'a, 'tcx: 'a>(
218218
let block_bcxs: IndexVec<mir::BasicBlock, BasicBlockRef> =
219219
mir.basic_blocks().indices().map(|bb| {
220220
if bb == mir::START_BLOCK {
221-
bcx.build_new_block("start").llbb()
221+
bcx.build_sibling_block("start").llbb()
222222
} else {
223-
bcx.build_new_block(&format!("{:?}", bb)).llbb()
223+
bcx.build_sibling_block(&format!("{:?}", bb)).llbb()
224224
}
225225
}).collect();
226226

src/librustc_trans/tvec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ pub fn slice_for_each<'a, 'tcx, F>(
2929
bcx.inbounds_gep(a, &[b])
3030
};
3131

32-
let body_bcx = bcx.build_new_block("slice_loop_body");
33-
let next_bcx = bcx.build_new_block("slice_loop_next");
34-
let header_bcx = bcx.build_new_block("slice_loop_header");
32+
let body_bcx = bcx.build_sibling_block("slice_loop_body");
33+
let next_bcx = bcx.build_sibling_block("slice_loop_next");
34+
let header_bcx = bcx.build_sibling_block("slice_loop_header");
3535

3636
let start = if zst {
3737
C_uint(bcx.ccx, 0usize)

0 commit comments

Comments
 (0)