Skip to content

Commit 4c9995a

Browse files
Simpliy block creation in MirContext
1 parent 37dd9f6 commit 4c9995a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/librustc_trans/mir/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use syntax::symbol::keywords;
3131
use syntax::abi::Abi;
3232

3333
use std::iter;
34-
use std::ffi::CString;
3534

3635
use rustc_data_structures::bitvec::BitVector;
3736
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
@@ -218,17 +217,10 @@ pub fn trans_mir<'a, 'tcx: 'a>(
218217
// Allocate a `Block` for every basic block
219218
let block_bcxs: IndexVec<mir::BasicBlock, BasicBlockRef> =
220219
mir.basic_blocks().indices().map(|bb| {
221-
let name = if bb == mir::START_BLOCK {
222-
CString::new("start").unwrap()
220+
if bb == mir::START_BLOCK {
221+
bcx.build_new_block("start").llbb()
223222
} else {
224-
CString::new(format!("{:?}", bb)).unwrap()
225-
};
226-
unsafe {
227-
llvm::LLVMAppendBasicBlockInContext(
228-
ccx.llcx(),
229-
llfn,
230-
name.as_ptr()
231-
)
223+
bcx.build_new_block(&format!("{:?}", bb)).llbb()
232224
}
233225
}).collect();
234226

0 commit comments

Comments
 (0)