]> git.lizzy.rs Git - rust.git/commitdiff
Builder.build_new_block -> Builder.build_sibling_block
authorMark Simulacrum <mark.simulacrum@gmail.com>
Mon, 2 Jan 2017 20:18:38 +0000 (13:18 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 4 Jan 2017 18:38:10 +0000 (11:38 -0700)
src/librustc_trans/builder.rs
src/librustc_trans/callee.rs
src/librustc_trans/cleanup.rs
src/librustc_trans/glue.rs
src/librustc_trans/intrinsic.rs
src/librustc_trans/mir/mod.rs
src/librustc_trans/tvec.rs

index 6112e29f72f4d366a3fe1994afb553afba3ec3e0..33e6cc82ad78898bf9e73f524e1a9d950b62936e 100644 (file)
@@ -80,18 +80,8 @@ pub fn with_ccx(ccx: &'a CrateContext<'a, 'tcx>) -> Self {
         }
     }
 
-    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 {
index c99dc7ee5ef4b9f70464d520d8440ad9336857a4..ae1086828b54226bc8cfd72e8d352bd9f5698a2f 100644 (file)
@@ -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 {
index d7ac5bee6d85a70c097ba354ead05af1f23243aa..5d89a67d3fd80890029273f3c6b01bfc64c406ac 100644 (file)
@@ -54,7 +54,7 @@ fn trans<'a>(&self, funclet: Option<&'a Funclet>, bcx: &Builder<'a, '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);
 
index 0c21573b9c43b4347fa22e5ba7709ffa508c5272..ab048ae6d9de27d2a5a338c37adc9085f4ee297c 100644 (file)
@@ -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 {
@@ -503,15 +503,15 @@ fn iter_variant<'a, 'tcx>(cx: &'a Builder<'a, '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);
index 35895e7827e1a5f0d7a23fbee65632e157897105..3848f3e0f6fdf1d512b531e9e5516277091ade95 100644 (file)
@@ -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);
@@ -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);
index 01fd7979be116f79f7cbbf67dccc3697f3b86771..603ded1c2d4ac1ac5d55358b728326b71738e2a3 100644 (file)
@@ -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();
 
index f6fc4637e1c06d3ca4010e24bbfbb763c3b19ab7..cbcbb02bdc89017ebb573ad6a9c06b57f2d94620 100644 (file)
@@ -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)