diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-02-18 15:37:31 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-02-24 12:18:21 +0100 |
| commit | 96cf7999ab64ead0c06384da51eb8586ffebfc1e (patch) | |
| tree | cdfaed89f7ad40550e40560013125b9026d8a8b8 /compiler/rustc_codegen_ssa/src | |
| parent | 0edcf1e2496caed074187c3c5ffac14537e633cf (diff) | |
| download | rust-96cf7999ab64ead0c06384da51eb8586ffebfc1e.tar.gz rust-96cf7999ab64ead0c06384da51eb8586ffebfc1e.zip | |
Introduce Bx::switch_to_block
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/block.rs | 19 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/builder.rs | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index ca46d230b72..39375b95b19 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -170,10 +170,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { } if let Some((ret_dest, target)) = destination { - let target_llbb = fx.llbb(target); - let mut ret_bx = Bx::build(fx.cx, target_llbb); - fx.set_debug_loc(&mut ret_bx, self.terminator.source_info); - fx.store_return(&mut ret_bx, ret_dest, &fn_abi.ret, invokeret); + bx.switch_to_block(fx.llbb(target)); + fx.set_debug_loc(bx, self.terminator.source_info); + fx.store_return(bx, ret_dest, &fn_abi.ret, invokeret); } } else { let llret = bx.call(fn_ty, fn_ptr, &llargs, self.funclet(fx)); @@ -462,7 +461,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } // After this point, bx is the block for the call to panic. - bx = Bx::build(self.cx, panic_block); + bx.switch_to_block(panic_block); self.set_debug_loc(&mut bx, terminator.source_info); // Get the location information. @@ -914,10 +913,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let bb_fail = bx.append_sibling_block("type_test.fail"); bx.cond_br(cond, bb_pass, bb_fail); - let mut bx_pass = Bx::build(self.cx, bb_pass); + bx.switch_to_block(bb_pass); helper.do_call( self, - &mut bx_pass, + &mut bx, fn_abi, fn_ptr, &llargs, @@ -925,9 +924,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { cleanup, ); - let mut bx_fail = Bx::build(self.cx, bb_fail); - bx_fail.abort(); - bx_fail.unreachable(); + bx.switch_to_block(bb_fail); + bx.abort(); + bx.unreachable(); return; } diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 6c7162c68d4..1c7fe060ea4 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -53,6 +53,8 @@ pub trait BuilderMethods<'a, 'tcx>: fn append_sibling_block(&mut self, name: &str) -> Self::BasicBlock; + fn switch_to_block(&mut self, llbb: Self::BasicBlock); + fn ret_void(&mut self); fn ret(&mut self, v: Self::Value); fn br(&mut self, dest: Self::BasicBlock); |
