Rename two TerminatorCodegenHelper
methods.
`TerminatorCodegenHelper` has three methods `llblock`, `llbb`, and `lltarget`. They're all similar, but the names given no indication of the differences. This commit renames `lltarget` as `llbb_with_landing_pad`, and `llblock` as `llbb_with_cleanup`. These aren't fantastic names, but at least it's now clear that `llbb` is the lowest-level of the three and the other two wrap it.
This commit is contained in:
parent
4e4092f8cc
commit
a5bd5da594
@ -63,7 +63,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lltarget<Bx: BuilderMethods<'a, 'tcx>>(
|
/// Get a basic block (creating it if necessary), possibly with a landing
|
||||||
|
/// pad next to it.
|
||||||
|
fn llbb_with_landing_pad<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
fx: &mut FunctionCx<'a, 'tcx, Bx>,
|
fx: &mut FunctionCx<'a, 'tcx, Bx>,
|
||||||
target: mir::BasicBlock,
|
target: mir::BasicBlock,
|
||||||
@ -83,17 +85,18 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a basic block.
|
/// Get a basic block (creating it if necessary), possibly with cleanup
|
||||||
fn llblock<Bx: BuilderMethods<'a, 'tcx>>(
|
/// stuff in it or next to it.
|
||||||
|
fn llbb_with_cleanup<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
fx: &mut FunctionCx<'a, 'tcx, Bx>,
|
fx: &mut FunctionCx<'a, 'tcx, Bx>,
|
||||||
target: mir::BasicBlock,
|
target: mir::BasicBlock,
|
||||||
) -> Bx::BasicBlock {
|
) -> Bx::BasicBlock {
|
||||||
let (lltarget, is_cleanupret) = self.lltarget(fx, target);
|
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
||||||
if is_cleanupret {
|
if is_cleanupret {
|
||||||
// MSVC cross-funclet jump - need a trampoline
|
// MSVC cross-funclet jump - need a trampoline
|
||||||
|
|
||||||
debug!("llblock: creating cleanup trampoline for {:?}", target);
|
debug!("llbb_with_cleanup: creating cleanup trampoline for {:?}", target);
|
||||||
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
|
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
|
||||||
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
|
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
|
||||||
let mut trampoline_bx = Bx::build(fx.cx, trampoline_llbb);
|
let mut trampoline_bx = Bx::build(fx.cx, trampoline_llbb);
|
||||||
@ -110,7 +113,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
target: mir::BasicBlock,
|
target: mir::BasicBlock,
|
||||||
) {
|
) {
|
||||||
let (lltarget, is_cleanupret) = self.lltarget(fx, target);
|
let (lltarget, is_cleanupret) = self.llbb_with_landing_pad(fx, target);
|
||||||
if is_cleanupret {
|
if is_cleanupret {
|
||||||
// micro-optimization: generate a `ret` rather than a jump
|
// micro-optimization: generate a `ret` rather than a jump
|
||||||
// to a trampoline.
|
// to a trampoline.
|
||||||
@ -138,7 +141,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||||||
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
|
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
|
||||||
|
|
||||||
let unwind_block = if let Some(cleanup) = cleanup.filter(|_| fn_abi.can_unwind) {
|
let unwind_block = if let Some(cleanup) = cleanup.filter(|_| fn_abi.can_unwind) {
|
||||||
Some(self.llblock(fx, cleanup))
|
Some(self.llbb_with_cleanup(fx, cleanup))
|
||||||
} else if fx.mir[self.bb].is_cleanup
|
} else if fx.mir[self.bb].is_cleanup
|
||||||
&& fn_abi.can_unwind
|
&& fn_abi.can_unwind
|
||||||
&& !base::wants_msvc_seh(fx.cx.tcx().sess)
|
&& !base::wants_msvc_seh(fx.cx.tcx().sess)
|
||||||
@ -231,7 +234,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||||||
options,
|
options,
|
||||||
line_spans,
|
line_spans,
|
||||||
instance,
|
instance,
|
||||||
Some((ret_llbb, self.llblock(fx, cleanup), self.funclet(fx))),
|
Some((ret_llbb, self.llbb_with_cleanup(fx, cleanup), self.funclet(fx))),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
bx.codegen_inline_asm(template, &operands, options, line_spans, instance, None);
|
bx.codegen_inline_asm(template, &operands, options, line_spans, instance, None);
|
||||||
@ -281,8 +284,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
if target_iter.len() == 1 {
|
if target_iter.len() == 1 {
|
||||||
// If there are two targets (one conditional, one fallback), emit br instead of switch
|
// If there are two targets (one conditional, one fallback), emit br instead of switch
|
||||||
let (test_value, target) = target_iter.next().unwrap();
|
let (test_value, target) = target_iter.next().unwrap();
|
||||||
let lltrue = helper.llblock(self, target);
|
let lltrue = helper.llbb_with_cleanup(self, target);
|
||||||
let llfalse = helper.llblock(self, targets.otherwise());
|
let llfalse = helper.llbb_with_cleanup(self, targets.otherwise());
|
||||||
if switch_ty == bx.tcx().types.bool {
|
if switch_ty == bx.tcx().types.bool {
|
||||||
// Don't generate trivial icmps when switching on bool
|
// Don't generate trivial icmps when switching on bool
|
||||||
match test_value {
|
match test_value {
|
||||||
@ -299,8 +302,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
} else {
|
} else {
|
||||||
bx.switch(
|
bx.switch(
|
||||||
discr.immediate(),
|
discr.immediate(),
|
||||||
helper.llblock(self, targets.otherwise()),
|
helper.llbb_with_cleanup(self, targets.otherwise()),
|
||||||
target_iter.map(|(value, target)| (value, helper.llblock(self, target))),
|
target_iter.map(|(value, target)| (value, helper.llbb_with_cleanup(self, target))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,7 +533,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
let cond = bx.expect(cond, expected);
|
let cond = bx.expect(cond, expected);
|
||||||
|
|
||||||
// Create the failure block and the conditional branch to it.
|
// Create the failure block and the conditional branch to it.
|
||||||
let lltarget = helper.llblock(self, target);
|
let lltarget = helper.llbb_with_cleanup(self, target);
|
||||||
let panic_block = bx.append_sibling_block("panic");
|
let panic_block = bx.append_sibling_block("panic");
|
||||||
if expected {
|
if expected {
|
||||||
bx.cond_br(cond, lltarget, panic_block);
|
bx.cond_br(cond, lltarget, panic_block);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user