Skip to content

Commit 626a5f5

Browse files
committed
Add assertions and clarify asm-goto with noreturn
1 parent 84bc9e9 commit 626a5f5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ pub(crate) fn inline_asm_call<'ll>(
465465
);
466466

467467
let call = if !labels.is_empty() {
468+
assert!(catch_funclet.is_none());
468469
bx.callbr(fty, None, None, v, inputs, dest.unwrap(), labels, None)
469470
} else if let Some((catch, funclet)) = catch_funclet {
470471
bx.invoke(fty, None, None, v, inputs, dest.unwrap(), catch, funclet)

compiler/rustc_codegen_ssa/src/mir/block.rs

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
265265
};
266266

267267
if operands.iter().any(|x| matches!(x, InlineAsmOperandRef::Label { .. })) {
268+
assert!(unwind_target.is_none());
268269
let ret_llbb = if let Some(target) = destination {
269270
fx.llbb(target)
270271
} else {

src/doc/unstable-book/src/language-features/asm-goto.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ unsafe {
2121
}
2222
```
2323

24-
The block must have unit type.
24+
The block must have unit type or diverge.
25+
26+
When `label <block>` is used together with `noreturn` option, it means that the
27+
assembly will not fallthrough. It's allowed to jump to a label within the
28+
assembly. In this case, the entire `asm!` expression will have an unit type as
29+
opposed to diverging, if not all label blocks diverge. The `asm!` expression
30+
still diverges if `noreturn` option is used and all label blocks diverge.

0 commit comments

Comments
 (0)