From: bjorn3 Date: Fri, 10 Jan 2020 11:14:28 +0000 (+0100) Subject: Prepare for basic blocks X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5424d7d55f88d293accc3f1a81f072b2c0b3df0e;p=rust.git Prepare for basic blocks --- diff --git a/src/base.rs b/src/base.rs index 7df6bb1ed5e..9a3a7870b0d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -182,11 +182,17 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } let cond = trans_operand(fx, cond).load_scalar(fx); let target = fx.get_ebb(*target); + let failure = fx.bcx.create_ebb(); if *expected { - fx.bcx.ins().brnz(cond, target, &[]); + fx.bcx.ins().brz(cond, failure, &[]); } else { - fx.bcx.ins().brz(cond, target, &[]); + fx.bcx.ins().brnz(cond, failure, &[]); }; + fx.bcx.ins().jump(target, &[]); + + // FIXME insert bb after all other bb's to reduce the amount of jumps in the common + // case and improve code locality. + fx.bcx.switch_to_block(failure); trap_panic( fx, format!(