mirror of https://github.com/rust-lang/rust.git
Add assertions and clarify asm-goto with noreturn
This commit is contained in:
parent
84bc9e9e36
commit
626a5f5892
|
@ -465,6 +465,7 @@ pub(crate) fn inline_asm_call<'ll>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let call = if !labels.is_empty() {
|
let call = if !labels.is_empty() {
|
||||||
|
assert!(catch_funclet.is_none());
|
||||||
bx.callbr(fty, None, None, v, inputs, dest.unwrap(), labels, None)
|
bx.callbr(fty, None, None, v, inputs, dest.unwrap(), labels, None)
|
||||||
} else if let Some((catch, funclet)) = catch_funclet {
|
} else if let Some((catch, funclet)) = catch_funclet {
|
||||||
bx.invoke(fty, None, None, v, inputs, dest.unwrap(), catch, funclet)
|
bx.invoke(fty, None, None, v, inputs, dest.unwrap(), catch, funclet)
|
||||||
|
|
|
@ -265,6 +265,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if operands.iter().any(|x| matches!(x, InlineAsmOperandRef::Label { .. })) {
|
if operands.iter().any(|x| matches!(x, InlineAsmOperandRef::Label { .. })) {
|
||||||
|
assert!(unwind_target.is_none());
|
||||||
let ret_llbb = if let Some(target) = destination {
|
let ret_llbb = if let Some(target) = destination {
|
||||||
fx.llbb(target)
|
fx.llbb(target)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue