use abort instead of unreachable
This commit is contained in:
parent
e5d50e3e88
commit
f5bd94768a
@ -261,7 +261,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
if self.fn_abi.ret.layout.abi.is_uninhabited() {
|
||||
// Functions with uninhabited return values are marked `noreturn`,
|
||||
// so we should make sure that we never actually do.
|
||||
// We play it safe by using a well-defined `abort`, but we could go for immediate UB
|
||||
// if that turns out to be helpful.
|
||||
bx.abort();
|
||||
// `abort` does not terminate the block, so we still need to generate
|
||||
// an `unreachable` terminator after it.
|
||||
bx.unreachable();
|
||||
return;
|
||||
}
|
||||
@ -825,6 +829,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
||||
mir::TerminatorKind::Abort => {
|
||||
bx.abort();
|
||||
// `abort` does not terminate the block, so we still need to generate
|
||||
// an `unreachable` terminator after it.
|
||||
bx.unreachable();
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||
variant_index: VariantIdx
|
||||
) {
|
||||
if self.layout.for_variant(bx.cx(), variant_index).abi.is_uninhabited() {
|
||||
bx.unreachable();
|
||||
// We play it safe by using a well-defined `abort`, but we could go for immediate UB
|
||||
// if that turns out to be helpful.
|
||||
bx.abort();
|
||||
return;
|
||||
}
|
||||
match self.layout.variants {
|
||||
|
@ -20,9 +20,9 @@ impl IntoError<Error> for Api
|
||||
{
|
||||
type Source = ApiError;
|
||||
// CHECK-LABEL: @into_error
|
||||
// CHECK: unreachable
|
||||
// Also check the next two instructions to make sure we do not match against `unreachable`
|
||||
// elsewhere in the code (e.g., in the closure bode).
|
||||
// CHECK: llvm.trap()
|
||||
// Also check the next two instructions to make sure we do not match against `trap`
|
||||
// elsewhere in the code.
|
||||
// CHECK-NEXT: load
|
||||
// CHECK-NEXT: ret
|
||||
#[no_mangle]
|
||||
|
Loading…
x
Reference in New Issue
Block a user