Skip to content

Commit 4e4092f

Browse files
committed
rustc_codegen_ssa: use more consistent naming.
Ensure: - builders always have a `bx` suffix; - backend basic blocks always have an `llbb` suffix, - paired builders and basic blocks have consistent prefixes.
1 parent 7fcf850 commit 4e4092f

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

Diff for: compiler/rustc_codegen_ssa/src/mir/block.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
9595

9696
debug!("llblock: creating cleanup trampoline for {:?}", target);
9797
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
98-
let trampoline = Bx::append_block(fx.cx, fx.llfn, name);
99-
let mut trampoline_bx = Bx::build(fx.cx, trampoline);
98+
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
99+
let mut trampoline_bx = Bx::build(fx.cx, trampoline_llbb);
100100
trampoline_bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
101-
trampoline
101+
trampoline_llbb
102102
} else {
103103
lltarget
104104
}
@@ -1459,20 +1459,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14591459
// bar();
14601460
// }
14611461
Some(&mir::TerminatorKind::Abort) => {
1462-
let cs_bb =
1462+
let cs_llbb =
14631463
Bx::append_block(self.cx, self.llfn, &format!("cs_funclet{:?}", bb));
1464-
let cp_bb =
1464+
let cp_llbb =
14651465
Bx::append_block(self.cx, self.llfn, &format!("cp_funclet{:?}", bb));
1466-
ret_llbb = cs_bb;
1466+
ret_llbb = cs_llbb;
14671467

1468-
let mut cs_bx = Bx::build(self.cx, cs_bb);
1469-
let cs = cs_bx.catch_switch(None, None, &[cp_bb]);
1468+
let mut cs_bx = Bx::build(self.cx, cs_llbb);
1469+
let cs = cs_bx.catch_switch(None, None, &[cp_llbb]);
14701470

14711471
// The "null" here is actually a RTTI type descriptor for the
14721472
// C++ personality function, but `catch (...)` has no type so
14731473
// it's null. The 64 here is actually a bitfield which
14741474
// represents that this is a catch-all block.
1475-
let mut cp_bx = Bx::build(self.cx, cp_bb);
1475+
let mut cp_bx = Bx::build(self.cx, cp_llbb);
14761476
let null = cp_bx.const_null(
14771477
cp_bx.type_i8p_ext(cp_bx.cx().data_layout().instruction_address_space),
14781478
);
@@ -1481,30 +1481,31 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14811481
cp_bx.br(llbb);
14821482
}
14831483
_ => {
1484-
let cleanup_bb =
1484+
let cleanup_llbb =
14851485
Bx::append_block(self.cx, self.llfn, &format!("funclet_{:?}", bb));
1486-
ret_llbb = cleanup_bb;
1487-
let mut cleanup_bx = Bx::build(self.cx, cleanup_bb);
1486+
ret_llbb = cleanup_llbb;
1487+
let mut cleanup_bx = Bx::build(self.cx, cleanup_llbb);
14881488
funclet = cleanup_bx.cleanup_pad(None, &[]);
14891489
cleanup_bx.br(llbb);
14901490
}
14911491
}
14921492
self.funclets[bb] = Some(funclet);
14931493
ret_llbb
14941494
} else {
1495-
let bb = Bx::append_block(self.cx, self.llfn, "cleanup");
1496-
let mut bx = Bx::build(self.cx, bb);
1495+
let cleanup_llbb = Bx::append_block(self.cx, self.llfn, "cleanup");
1496+
let mut cleanup_bx = Bx::build(self.cx, cleanup_llbb);
14971497

14981498
let llpersonality = self.cx.eh_personality();
14991499
let llretty = self.landing_pad_type();
1500-
let lp = bx.cleanup_landing_pad(llretty, llpersonality);
1500+
let lp = cleanup_bx.cleanup_landing_pad(llretty, llpersonality);
15011501

1502-
let slot = self.get_personality_slot(&mut bx);
1503-
slot.storage_live(&mut bx);
1504-
Pair(bx.extract_value(lp, 0), bx.extract_value(lp, 1)).store(&mut bx, slot);
1502+
let slot = self.get_personality_slot(&mut cleanup_bx);
1503+
slot.storage_live(&mut cleanup_bx);
1504+
Pair(cleanup_bx.extract_value(lp, 0), cleanup_bx.extract_value(lp, 1))
1505+
.store(&mut cleanup_bx, slot);
15051506

1506-
bx.br(llbb);
1507-
bx.llbb()
1507+
cleanup_bx.br(llbb);
1508+
cleanup_llbb
15081509
}
15091510
}
15101511

Diff for: compiler/rustc_codegen_ssa/src/mir/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
148148
let debug_context = cx.create_function_debug_context(instance, &fn_abi, llfn, &mir);
149149

150150
let start_llbb = Bx::append_block(cx, llfn, "start");
151-
let mut bx = Bx::build(cx, start_llbb);
151+
let mut start_bx = Bx::build(cx, start_llbb);
152152

153153
if mir.basic_blocks.iter().any(|bb| bb.is_cleanup) {
154-
bx.set_personality_fn(cx.eh_personality());
154+
start_bx.set_personality_fn(cx.eh_personality());
155155
}
156156

157157
let cleanup_kinds = analyze::cleanup_kinds(&mir);
@@ -180,7 +180,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
180180
caller_location: None,
181181
};
182182

183-
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut bx);
183+
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut start_bx);
184184

185185
// Evaluate all required consts; codegen later assumes that CTFE will never fail.
186186
let mut all_consts_ok = true;
@@ -206,29 +206,29 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
206206

207207
// Allocate variable and temp allocas
208208
fx.locals = {
209-
let args = arg_local_refs(&mut bx, &mut fx, &memory_locals);
209+
let args = arg_local_refs(&mut start_bx, &mut fx, &memory_locals);
210210

211211
let mut allocate_local = |local| {
212212
let decl = &mir.local_decls[local];
213-
let layout = bx.layout_of(fx.monomorphize(decl.ty));
213+
let layout = start_bx.layout_of(fx.monomorphize(decl.ty));
214214
assert!(!layout.ty.has_erasable_regions());
215215

216216
if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {
217217
debug!("alloc: {:?} (return place) -> place", local);
218-
let llretptr = bx.get_param(0);
218+
let llretptr = start_bx.get_param(0);
219219
return LocalRef::Place(PlaceRef::new_sized(llretptr, layout));
220220
}
221221

222222
if memory_locals.contains(local) {
223223
debug!("alloc: {:?} -> place", local);
224224
if layout.is_unsized() {
225-
LocalRef::UnsizedPlace(PlaceRef::alloca_unsized_indirect(&mut bx, layout))
225+
LocalRef::UnsizedPlace(PlaceRef::alloca_unsized_indirect(&mut start_bx, layout))
226226
} else {
227-
LocalRef::Place(PlaceRef::alloca(&mut bx, layout))
227+
LocalRef::Place(PlaceRef::alloca(&mut start_bx, layout))
228228
}
229229
} else {
230230
debug!("alloc: {:?} -> operand", local);
231-
LocalRef::new_operand(&mut bx, layout)
231+
LocalRef::new_operand(&mut start_bx, layout)
232232
}
233233
};
234234

@@ -240,7 +240,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
240240
};
241241

242242
// Apply debuginfo to the newly allocated locals.
243-
fx.debug_introduce_locals(&mut bx);
243+
fx.debug_introduce_locals(&mut start_bx);
244244

245245
// Codegen the body of each block using reverse postorder
246246
for (bb, _) in traversal::reverse_postorder(&mir) {

0 commit comments

Comments
 (0)