Skip to content

Commit bf3ef0d

Browse files
committed
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.
1 parent e980c62 commit bf3ef0d

File tree

1 file changed

+5
-0
lines changed
  • compiler/rustc_codegen_llvm/src

1 file changed

+5
-0
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
290290
}
291291
attributes::apply_to_callsite(result, llvm::AttributePlace::Function, &{ attrs });
292292

293+
// Switch to the 'normal' basic block if we did an `invoke` instead of a `call`
294+
if let Some((dest, _, _)) = dest_catch_funclet {
295+
self.switch_to_block(dest);
296+
}
297+
293298
// Write results to outputs
294299
for (idx, op) in operands.iter().enumerate() {
295300
if let InlineAsmOperandRef::Out { reg, place: Some(place), .. }

0 commit comments

Comments
 (0)