Add assertions and clarify asm-goto with noreturn

This commit is contained in:
Gary Guo 2024-02-24 17:12:25 +00:00
parent 84bc9e9e36
commit 626a5f5892
3 changed files with 9 additions and 1 deletions

View File

@ -465,6 +465,7 @@ pub(crate) fn inline_asm_call<'ll>(
);
let call = if !labels.is_empty() {
assert!(catch_funclet.is_none());
bx.callbr(fty, None, None, v, inputs, dest.unwrap(), labels, None)
} else if let Some((catch, funclet)) = catch_funclet {
bx.invoke(fty, None, None, v, inputs, dest.unwrap(), catch, funclet)

View File

@ -265,6 +265,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
};
if operands.iter().any(|x| matches!(x, InlineAsmOperandRef::Label { .. })) {
assert!(unwind_target.is_none());
let ret_llbb = if let Some(target) = destination {
fx.llbb(target)
} else {

View File

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