diff options
| author | Luqman Aden <me@luqman.ca> | 2022-04-09 15:25:46 -0400 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2022-04-09 15:25:46 -0400 |
| commit | bf3ef0da0c630ab239e4f26e86602eabe585e74f (patch) | |
| tree | 659834049ae9c41b5ca57e1777e198c31913a5c7 /compiler/rustc_codegen_llvm/src/asm.rs | |
| parent | e980c6295582792e4a7c2d67e33cece60c170115 (diff) | |
| download | rust-bf3ef0da0c630ab239e4f26e86602eabe585e74f.tar.gz rust-bf3ef0da0c630ab239e4f26e86602eabe585e74f.zip | |
Switch to the 'normal' basic block for writing asm outputs if needed.
We may sometimes emit an `invoke` instead of a `call` for inline assembly during the MIR -> LLVM IR lowering. But we failed to update the IR builder's current basic block before writing the results to the outputs. This would result in invalid IR because the basic block would end in a `store` instruction, which isn't a valid terminator.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/asm.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/asm.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index 03c390b4bd4..91d132eb343 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -290,6 +290,11 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { } attributes::apply_to_callsite(result, llvm::AttributePlace::Function, &{ attrs }); + // Switch to the 'normal' basic block if we did an `invoke` instead of a `call` + if let Some((dest, _, _)) = dest_catch_funclet { + self.switch_to_block(dest); + } + // Write results to outputs for (idx, op) in operands.iter().enumerate() { if let InlineAsmOperandRef::Out { reg, place: Some(place), .. } |
