]> git.lizzy.rs Git - rust.git/commitdiff
Prepare for basic blocks
authorbjorn3 <bjorn3@users.noreply.github.com>
Fri, 10 Jan 2020 11:14:28 +0000 (12:14 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Fri, 10 Jan 2020 11:14:28 +0000 (12:14 +0100)
src/base.rs

index 7df6bb1ed5e04eb318c33259a0847bfc9af05c6d..9a3a7870b0dfa7d9e9e89a9b366c31c9bdcf1230 100644 (file)
@@ -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!(