diff options
| author | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-05 09:13:28 +0100 |
|---|---|---|
| committer | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-11 09:32:08 +0000 |
| commit | cf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch) | |
| tree | 40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/codegen/try_question_mark_nop.rs | |
| parent | ca855e6e42787ecd062d81d53336fe6788ef51a9 (diff) | |
| download | rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip | |
Move /src/test to /tests
Diffstat (limited to 'tests/codegen/try_question_mark_nop.rs')
| -rw-r--r-- | tests/codegen/try_question_mark_nop.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs new file mode 100644 index 00000000000..d239387768e --- /dev/null +++ b/tests/codegen/try_question_mark_nop.rs @@ -0,0 +1,54 @@ +// min-llvm-version: 15.0 +// compile-flags: -O -Z merge-functions=disabled --edition=2021 +// only-x86_64 + +#![crate_type = "lib"] +#![feature(try_blocks)] + +// These are now NOPs in LLVM 15, presumably thanks to nikic's change mentioned in +// <https://github.com/rust-lang/rust/issues/85133#issuecomment-1072168354>. +// Unfortunately, as of 2022-08-17 they're not yet nops for `u64`s nor `Option`. + +use std::ops::ControlFlow::{self, Continue, Break}; + +// CHECK-LABEL: @result_nop_match_32 +#[no_mangle] +pub fn result_nop_match_32(x: Result<i32, u32>) -> Result<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + match x { + Ok(x) => Ok(x), + Err(x) => Err(x), + } +} + +// CHECK-LABEL: @result_nop_traits_32 +#[no_mangle] +pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + try { + x? + } +} + +// CHECK-LABEL: @control_flow_nop_match_32 +#[no_mangle] +pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + match x { + Continue(x) => Continue(x), + Break(x) => Break(x), + } +} + +// CHECK-LABEL: @control_flow_nop_traits_32 +#[no_mangle] +pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + try { + x? + } +} |
