From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/codegen/try_question_mark_nop.rs | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/codegen/try_question_mark_nop.rs (limited to 'tests/codegen/try_question_mark_nop.rs') diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs new file mode 100644 index 000000000..d23938776 --- /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 +// . +// 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) -> Result { + // 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) -> Result { + // 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) -> ControlFlow { + // 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) -> ControlFlow { + // CHECK: start + // CHECK-NEXT: ret i64 %0 + try { + x? + } +} -- cgit v1.2.3