Skip to content

Commit 5424d7d

Browse files
committed
Prepare for basic blocks
1 parent 72729e2 commit 5424d7d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/base.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,17 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
182182
}
183183
let cond = trans_operand(fx, cond).load_scalar(fx);
184184
let target = fx.get_ebb(*target);
185+
let failure = fx.bcx.create_ebb();
185186
if *expected {
186-
fx.bcx.ins().brnz(cond, target, &[]);
187+
fx.bcx.ins().brz(cond, failure, &[]);
187188
} else {
188-
fx.bcx.ins().brz(cond, target, &[]);
189+
fx.bcx.ins().brnz(cond, failure, &[]);
189190
};
191+
fx.bcx.ins().jump(target, &[]);
192+
193+
// FIXME insert bb after all other bb's to reduce the amount of jumps in the common
194+
// case and improve code locality.
195+
fx.bcx.switch_to_block(failure);
190196
trap_panic(
191197
fx,
192198
format!(

0 commit comments

Comments
 (0)