diff options
| author | bors <bors@rust-lang.org> | 2022-08-20 17:38:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-20 17:38:29 +0000 |
| commit | 48853a361a5ff0e8215301c62f259a26eed7aa72 (patch) | |
| tree | c489e6126995afb021a83e16c75797964e3d6983 /src/test/codegen | |
| parent | dd01122b5c62a04e64b4109c5576eeea9ae4145b (diff) | |
| parent | 0be081976cba41453e61195a58c3dca097763549 (diff) | |
Auto merge of #100809 - matthiaskrgr:rollup-xkpd5ii, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #99415 (Initial implementation of REUSE) - #99544 (Expose `Utf8Lossy` as `Utf8Chunks`) - #100585 (Fix trailing space showing up in example) - #100596 (Remove unnecessary stderr files) - #100642 (Update fortanix-sgx-abi and export some useful SGX usercall traits) - #100691 (Make `same_type_modulo_infer` a proper `TypeRelation`) - #100693 (Add LLVM15-specific codegen test for `try`/`?`s that now optimize away) - #100710 (Windows: Load synch functions together) - #100807 (Add TaKO8Ki to translation-related mention groups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/try_question_mark_nop.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/codegen/try_question_mark_nop.rs b/src/test/codegen/try_question_mark_nop.rs new file mode 100644 index 00000000000..d239387768e --- /dev/null +++ b/src/test/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? + } +} |
