Skip to content

Commit e142cdf

Browse files
committed
Remove FunctionCx::new_block
1 parent e6d7a8d commit e142cdf

File tree

1 file changed

+24
-22
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+24
-22
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

+24-22
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
9696

9797
debug!("llblock: creating cleanup trampoline for {:?}", target);
9898
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
99-
let mut trampoline = fx.new_block(name);
100-
trampoline.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
101-
trampoline.llbb()
99+
let trampoline = Bx::append_block(fx.cx, fx.llfn, name);
100+
let mut trampoline_bx = Bx::build(fx.cx, trampoline);
101+
trampoline_bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
102+
trampoline
102103
} else {
103104
lltarget
104105
}
@@ -1358,16 +1359,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13581359
// bar();
13591360
// }
13601361
Some(&mir::TerminatorKind::Abort) => {
1361-
let mut cs_bx = self.new_block(&format!("cs_funclet{:?}", bb));
1362-
let mut cp_bx = self.new_block(&format!("cp_funclet{:?}", bb));
1363-
ret_llbb = cs_bx.llbb();
1362+
let cs_bb =
1363+
Bx::append_block(self.cx, self.llfn, &format!("cs_funclet{:?}", bb));
1364+
let cp_bb =
1365+
Bx::append_block(self.cx, self.llfn, &format!("cp_funclet{:?}", bb));
1366+
ret_llbb = cs_bb;
13641367

1365-
let cs = cs_bx.catch_switch(None, None, &[cp_bx.llbb()]);
1368+
let mut cs_bx = Bx::build(self.cx, cs_bb);
1369+
let cs = cs_bx.catch_switch(None, None, &[cp_bb]);
13661370

13671371
// The "null" here is actually a RTTI type descriptor for the
13681372
// C++ personality function, but `catch (...)` has no type so
13691373
// it's null. The 64 here is actually a bitfield which
13701374
// represents that this is a catch-all block.
1375+
let mut cp_bx = Bx::build(self.cx, cp_bb);
13711376
let null = cp_bx.const_null(
13721377
cp_bx.type_i8p_ext(cp_bx.cx().data_layout().instruction_address_space),
13731378
);
@@ -1376,16 +1381,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13761381
cp_bx.br(llbb);
13771382
}
13781383
_ => {
1379-
let mut cleanup_bx = self.new_block(&format!("funclet_{:?}", bb));
1380-
ret_llbb = cleanup_bx.llbb();
1384+
let cleanup_bb =
1385+
Bx::append_block(self.cx, self.llfn, &format!("funclet_{:?}", bb));
1386+
ret_llbb = cleanup_bb;
1387+
let mut cleanup_bx = Bx::build(self.cx, cleanup_bb);
13811388
funclet = cleanup_bx.cleanup_pad(None, &[]);
13821389
cleanup_bx.br(llbb);
13831390
}
13841391
}
13851392
self.funclets[bb] = Some(funclet);
13861393
ret_llbb
13871394
} else {
1388-
let mut bx = self.new_block("cleanup");
1395+
let bb = Bx::append_block(self.cx, self.llfn, "cleanup");
1396+
let mut bx = Bx::build(self.cx, bb);
13891397

13901398
let llpersonality = self.cx.eh_personality();
13911399
let llretty = self.landing_pad_type();
@@ -1407,18 +1415,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14071415

14081416
fn unreachable_block(&mut self) -> Bx::BasicBlock {
14091417
self.unreachable_block.unwrap_or_else(|| {
1410-
let mut bx = self.new_block("unreachable");
1418+
let llbb = Bx::append_block(self.cx, self.llfn, "unreachable");
1419+
let mut bx = Bx::build(self.cx, llbb);
14111420
bx.unreachable();
1412-
self.unreachable_block = Some(bx.llbb());
1413-
bx.llbb()
1421+
self.unreachable_block = Some(llbb);
1422+
llbb
14141423
})
14151424
}
14161425

14171426
fn double_unwind_guard(&mut self) -> Bx::BasicBlock {
14181427
self.double_unwind_guard.unwrap_or_else(|| {
14191428
assert!(!base::wants_msvc_seh(self.cx.sess()));
14201429

1421-
let mut bx = self.new_block("abort");
1430+
let llbb = Bx::append_block(self.cx, self.llfn, "abort");
1431+
let mut bx = Bx::build(self.cx, llbb);
14221432
self.set_debug_loc(&mut bx, mir::SourceInfo::outermost(self.mir.span));
14231433

14241434
let llpersonality = self.cx.eh_personality();
@@ -1436,20 +1446,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14361446
bx.apply_attrs_to_cleanup_callsite(llret);
14371447

14381448
bx.unreachable();
1439-
let llbb = bx.llbb();
14401449

14411450
self.double_unwind_guard = Some(llbb);
14421451
llbb
14431452
})
14441453
}
14451454

1446-
// FIXME(eddyb) replace with `append_sibling_block`
1447-
// (which requires having a `Bx` already, and not all callers do).
1448-
fn new_block(&self, name: &str) -> Bx {
1449-
let llbb = Bx::append_block(self.cx, self.llfn, name);
1450-
Bx::build(self.cx, llbb)
1451-
}
1452-
14531455
/// Get the backend `BasicBlock` for a MIR `BasicBlock`, either already
14541456
/// cached in `self.cached_llbbs`, or created on demand (and cached).
14551457
// FIXME(eddyb) rename `llbb` and other `ll`-prefixed things to use a

0 commit comments

Comments
 (0)