diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-10 09:29:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-10 09:29:44 +0000 |
| commit | a839fbf0a11bcfc2d594daeab3262f540d4b6178 (patch) | |
| tree | a0cb06654acfe3d0136f7e59c87b12f591903512 /tests/codegen | |
| parent | 5ff90d069a2d9c1391c811278b9c50550e6861dc (diff) | |
| parent | a01f37c7f49b4bcdd4565bd642f68b289a25d832 (diff) | |
| download | rust-a839fbf0a11bcfc2d594daeab3262f540d4b6178.tar.gz rust-a839fbf0a11bcfc2d594daeab3262f540d4b6178.zip | |
Merge pull request #4021 from RalfJung/rustup
Rustup
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/asm/s390x-clobbers.rs | 2 | ||||
| -rw-r--r-- | tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs | 11 | ||||
| -rw-r--r-- | tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs | 53 | ||||
| -rw-r--r-- | tests/codegen/function-arguments.rs | 24 | ||||
| -rw-r--r-- | tests/codegen/try_question_mark_nop.rs | 11 |
5 files changed, 95 insertions, 6 deletions
diff --git a/tests/codegen/asm/s390x-clobbers.rs b/tests/codegen/asm/s390x-clobbers.rs index 45f72206bdf..56d82b4b044 100644 --- a/tests/codegen/asm/s390x-clobbers.rs +++ b/tests/codegen/asm/s390x-clobbers.rs @@ -3,7 +3,7 @@ //@[s390x] needs-llvm-components: systemz #![crate_type = "rlib"] -#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)] +#![feature(no_core, rustc_attrs, lang_items)] #![no_core] #[lang = "sized"] diff --git a/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs new file mode 100644 index 00000000000..159ecfd0974 --- /dev/null +++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs @@ -0,0 +1,11 @@ +//@ force-host +//@ no-prefer-dynamic +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn square_twice(_item: TokenStream) -> TokenStream { + "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() +} diff --git a/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs new file mode 100644 index 00000000000..c3858044c0c --- /dev/null +++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs @@ -0,0 +1,53 @@ +//@ min-llvm-version: 19 +//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline +// MSVC is different because of the individual allocas. +//@ ignore-msvc + +//@ aux-build:macro_def.rs + +// Find the variable. +// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] + +// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking +// backwards. +// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) +// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) + +// Find the first location definition, looking forwards again. +// CHECK: ![[#var_loc1]] = !DILocation +// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] + +// Find the first location's inlinedAt +// NB: If we fail here it's *probably* because we failed to produce two +// different locations and ended up reusing an earlier one. +// CHECK: ![[#var_inlinedAt1]] = !DILocation +// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] + +// Find the second location definition, still looking forwards. +// NB: If we failed to produce two different locations, the test will +// definitely fail by this point (if it hasn't already) because we won't +// be able to find the same line again. +// CHECK: ![[#var_loc2]] = !DILocation +// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] + +// Find the second location's inlinedAt. +// CHECK: ![[#var_inlinedAt2]] = !DILocation +// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] + +// Finally, check that a discriminator was emitted for the second scope. +// FIXMEkhuey ideally we would check that *either* scope has a discriminator +// but I don't know that it's possible to check that with FileCheck. +// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile +// CHECK-SAME: discriminator: [[#]] +extern crate macro_def; + +use std::env; + +fn square(n: i32) -> i32 { + n * n +} + +fn main() { + let (z1, z2) = macro_def::square_twice!(); + println!("{z1} == {z2}"); +} diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 7fa1d659885..503799d3ed2 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,5 +1,6 @@ //@ compile-flags: -O -C no-prepopulate-passes #![crate_type = "lib"] +#![feature(rustc_attrs)] #![feature(dyn_star)] #![feature(allocator_api)] @@ -143,13 +144,28 @@ pub fn indirect_struct(_: S) {} #[no_mangle] pub fn borrowed_struct(_: &S) {} -// CHECK: @option_borrow(ptr noalias noundef readonly align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow(ptr noalias noundef readonly align 4 dereferenceable_or_null(4) %_x) #[no_mangle] -pub fn option_borrow(x: Option<&i32>) {} +pub fn option_borrow(_x: Option<&i32>) {} -// CHECK: @option_borrow_mut(ptr noalias noundef align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow_mut(ptr noalias noundef align 4 dereferenceable_or_null(4) %_x) #[no_mangle] -pub fn option_borrow_mut(x: Option<&mut i32>) {} +pub fn option_borrow_mut(_x: Option<&mut i32>) {} + +// Function that must NOT have `dereferenceable` or `align`. +#[rustc_layout_scalar_valid_range_start(16)] +pub struct RestrictedAddress(&'static i16); +enum E { + A(RestrictedAddress), + B, + C, +} +// If the `nonnull` ever goes missing, you might have to tweak the +// scalar_valid_range on `RestrictedAddress` to get it back. You +// might even have to add a `rustc_layout_scalar_valid_range_end`. +// CHECK: @nonnull_and_nondereferenceable(ptr noundef nonnull %_x) +#[no_mangle] +pub fn nonnull_and_nondereferenceable(_x: E) {} // CHECK: @raw_struct(ptr noundef %_1) #[no_mangle] diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index bbab0d9eb1d..b68ecce869e 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -1,6 +1,10 @@ //@ compile-flags: -O -Z merge-functions=disabled --edition=2021 //@ only-x86_64 // FIXME: Remove the `min-llvm-version`. +//@ revisions: NINETEEN TWENTY +//@[NINETEEN] min-llvm-version: 19 +//@[NINETEEN] ignore-llvm-version: 20-99 +//@[TWENTY] min-llvm-version: 20 //@ min-llvm-version: 19 #![crate_type = "lib"] @@ -13,8 +17,11 @@ use std::ptr::NonNull; #[no_mangle] pub fn option_nop_match_32(x: Option<u32>) -> Option<u32> { // CHECK: start: + // TWENTY-NEXT: %trunc = trunc nuw i32 %0 to i1 + // TWENTY-NEXT: %.2 = select i1 %trunc, i32 %1, i32 undef // CHECK-NEXT: [[REG1:%.*]] = insertvalue { i32, i32 } poison, i32 %0, 0 - // CHECK-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } [[REG1]], i32 %1, 1 + // NINETEEN-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } [[REG1]], i32 %1, 1 + // TWENTY-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } [[REG1]], i32 %.2, 1 // CHECK-NEXT: ret { i32, i32 } [[REG2]] match x { Some(x) => Some(x), @@ -26,6 +33,8 @@ pub fn option_nop_match_32(x: Option<u32>) -> Option<u32> { #[no_mangle] pub fn option_nop_traits_32(x: Option<u32>) -> Option<u32> { // CHECK: start: + // TWENTY-NEXT: %trunc = trunc nuw i32 %0 to i1 + // TWENTY-NEXT: %.1 = select i1 %trunc, i32 %1, i32 undef // CHECK-NEXT: insertvalue { i32, i32 } // CHECK-NEXT: insertvalue { i32, i32 } // CHECK-NEXT: ret { i32, i32 } |
