diff --git a/.cirrus.yml b/.cirrus.yml index fec44bc13b40..aed08ced0756 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -110,7 +110,7 @@ run_cheri_tests_task: check_env_script: env pull_main_script: git fetch origin main:refs/remotes/origin/main --depth 1 build_rustc_script: CC="clang" CXX="clang++" ./x build compiler std --target=riscv32cheriot-unknown-cheriotrtos - build_rust_tests_script: CC="clang" CXX="clang++" ./x test tests/codegen-llvm/cheri-intrinsics.rs --target=riscv32cheriot-unknown-cheriotrtos + run_x_cheriot_tests_task: CC="clang" CXX="clang++" ./x test tests/codegen-llvm --target=riscv32cheriot-unknown-cheriotrtos --skip src/tools/linkchecker build_test_runner_script: cd ./cheri/tests/runner && . "$CARGO_HOME/env" && cargo build --release run_tests_script: cd ./cheri/tests && ./runner/target/release/cheriot-runner -vvvvv . --sysroot=../../build/host/llvm diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index d8472691afdf..505c6a1940e4 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -770,6 +770,10 @@ impl Config { *&self.target_cfg().pointer_width } + pub fn get_default_address_space(&self) -> Option { + *&self.target_cfg().default_address_space + } + pub fn can_unwind(&self) -> bool { self.target_cfg().panic == PanicStrategy::Unwind } @@ -1031,6 +1035,9 @@ pub struct TargetCfg { /// Supported target atomic widths: e.g. `8` to `128` or `ptr`. This is derived from the builtin /// `target_has_atomic` `cfg`s e.g. `target_has_atomic="8"`. pub(crate) target_has_atomic: BTreeSet, + + #[serde(rename = "default-address-space", default)] + pub(crate) default_address_space: Option, } impl TargetCfg { diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index c154886ebcde..9199afd9c34a 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -356,7 +356,8 @@ impl TestProps { fn load_from(&mut self, testfile: &Utf8Path, test_revision: Option<&str>, config: &Config) { if !testfile.is_dir() { let file_contents = fs::read_to_string(testfile).unwrap(); - let file_directives = FileDirectives::from_file_contents(testfile, &file_contents); + let file_directives = + FileDirectives::from_file_contents(config.suite, testfile, &file_contents); iter_directives( config.mode, diff --git a/src/tools/compiletest/src/directives/file.rs b/src/tools/compiletest/src/directives/file.rs index 82819ac0c8f0..96046cd49fca 100644 --- a/src/tools/compiletest/src/directives/file.rs +++ b/src/tools/compiletest/src/directives/file.rs @@ -8,15 +8,42 @@ pub(crate) struct FileDirectives<'a> { } impl<'a> FileDirectives<'a> { - pub(crate) fn from_file_contents(path: &'a Utf8Path, file_contents: &'a str) -> Self { + /// Create a new [`FileDirectives`] by iterating through the lines of `file_contents`. + /// + /// # Note + /// + /// When the `suite` argument matches [`crate::common::TestSuite::CodegenLlvm`] a synthetic + /// `needs-target-std` directive is inserted if needed - that is, if the file does not contain a + /// `#![no_std]` annotation. + /// + /// The objective of this addition is that of making it at least a bit easier to run + /// the codegen-llvm test suite for targets that do not have a stdlib, without forcing test + /// writers to remember yet another directive. + pub(crate) fn from_file_contents( + suite: crate::common::TestSuite, + path: &'a Utf8Path, + file_contents: &'a str, + ) -> Self { let mut lines = vec![]; + let mut generate_needs_std_stub = true; for (line_number, ln) in (1..).zip(file_contents.lines()) { let ln = ln.trim(); if let Some(directive_line) = line_directive(path, line_number, ln) { + if directive_line.name == "needs-target-std" { + generate_needs_std_stub = false; + } lines.push(directive_line); } + + if ln == "#![no_std]" || ln == "#![no_core]" { + generate_needs_std_stub = false; + } + } + + if generate_needs_std_stub && matches!(suite, crate::common::TestSuite::CodegenLlvm) { + lines.insert(0, crate::directives::line::generate_needs_std(path)) } Self { path, lines } diff --git a/src/tools/compiletest/src/directives/line.rs b/src/tools/compiletest/src/directives/line.rs index 16dd9a8de1c0..afc14abfa3b3 100644 --- a/src/tools/compiletest/src/directives/line.rs +++ b/src/tools/compiletest/src/directives/line.rs @@ -39,6 +39,19 @@ pub(crate) fn line_directive<'a>( Some(DirectiveLine { file_path, line_number, revision, raw_directive, name }) } +/// Generate a synthetic [`DirectiveLine`] to add the "needs-target-std" directive to a specific +/// test. See [`crate::FileDirectives::from_file_contents`] for an explanation why this is needed. +#[inline] +pub(crate) fn generate_needs_std<'a>(file_path: &'a Utf8Path) -> DirectiveLine<'a> { + DirectiveLine { + file_path, + line_number: 0, + revision: None, + raw_directive: "needs-target-std", + name: "needs-target-std", + } +} + /// The (partly) broken-down contents of a line containing a test directive, /// which `iter_directives` passes to its callback function. /// diff --git a/src/tools/compiletest/src/directives/tests.rs b/src/tools/compiletest/src/directives/tests.rs index 90e2cb77e304..d1f65b768a71 100644 --- a/src/tools/compiletest/src/directives/tests.rs +++ b/src/tools/compiletest/src/directives/tests.rs @@ -49,7 +49,7 @@ fn make_test_description( ) -> CollectedTestDesc { let cache = DirectivesCache::load(config); let mut poisoned = false; - let file_directives = FileDirectives::from_file_contents(path, file_contents); + let file_directives = FileDirectives::from_file_contents(config.suite, path, file_contents); let mut aux_props = AuxProps::default(); let test = crate::directives::make_test_description( @@ -259,7 +259,8 @@ fn cfg() -> ConfigBuilder { } fn parse_early_props(config: &Config, contents: &str) -> EarlyProps { - let file_directives = FileDirectives::from_file_contents(Utf8Path::new("a.rs"), contents); + let file_directives = + FileDirectives::from_file_contents(config.suite, Utf8Path::new("a.rs"), contents); EarlyProps::from_file_directives(config, &file_directives) } @@ -820,7 +821,12 @@ fn threads_support() { } fn run_path(poisoned: &mut bool, path: &Utf8Path, file_contents: &str) { - let file_directives = FileDirectives::from_file_contents(path, file_contents); + let file_directives = FileDirectives::from_file_contents( + // Arbitrary suite to prevent from_file_contents to add synthetic directives. + crate::common::TestSuite::Coverage, + path, + file_contents, + ); let result = directives::do_early_directives_check(TestMode::Ui, &file_directives); if result.is_err() { *poisoned = true; diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index acd0d70d081f..e7bbdc88cb9d 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -871,7 +871,8 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te // Scan the test file to discover its revisions, if any. let file_contents = fs::read_to_string(&test_path).expect("reading test file for directives should succeed"); - let file_directives = FileDirectives::from_file_contents(&test_path, &file_contents); + let file_directives = + FileDirectives::from_file_contents(cx.config.suite, &test_path, &file_contents); if let Err(message) = directives::do_early_directives_check(cx.config.mode, &file_directives) { // FIXME(Zalathar): Overhaul compiletest error handling so that we diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 54d6e0190ddc..41402a5f5fb0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2142,6 +2142,17 @@ impl<'test> TestCx<'test> { filecheck.arg("--check-prefix").arg(rev); } + // HACK: Some targets use a default address space that is different + // from the default one in LLVM. + // This variable is set to make it slightly easier to adapt existing + // tests to those targets using the [[ADDRSPACE]] variable. + if let Some(address_space) = self.config.get_default_address_space() { + // The leading whitespace is intended. + filecheck.arg(format!("-DADDRSPACE= addrspace({})", address_space)); + } else { + filecheck.arg("-DADDRSPACE="); + } + // HACK: the filecheck tool normally fails if a prefix is defined but not used. However, // sometimes revisions are used to specify *compiletest* directives which are not FileCheck // concerns. diff --git a/tests/codegen-llvm/addr-of-mutate.rs b/tests/codegen-llvm/addr-of-mutate.rs index d59d85af62a9..46fae040d90e 100644 --- a/tests/codegen-llvm/addr-of-mutate.rs +++ b/tests/codegen-llvm/addr-of-mutate.rs @@ -1,11 +1,12 @@ //@ compile-flags: -C opt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] // Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. // See . -// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}} dereferenceable(128) %x) +// CHECK: i8 @foo(ptr[[ADDRSPACE]]{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}} dereferenceable(128) %x) #[no_mangle] pub fn foo(x: [u8; 128]) -> u8 { let ptr = core::ptr::addr_of!(x).cast_mut(); @@ -15,7 +16,7 @@ pub fn foo(x: [u8; 128]) -> u8 { x[0] } -// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @second(ptr[[ADDRSPACE]]{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); @@ -24,7 +25,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { } // If going through a deref (and there are no other mutating accesses), then `readonly` is fine. -// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @third(ptr[[ADDRSPACE]]{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); diff --git a/tests/codegen-llvm/adjustments.rs b/tests/codegen-llvm/adjustments.rs index 7f7831def083..89552fef1216 100644 --- a/tests/codegen-llvm/adjustments.rs +++ b/tests/codegen-llvm/adjustments.rs @@ -1,9 +1,10 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] +#![no_std] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] #[no_mangle] pub fn helper(_: usize) {} @@ -12,9 +13,9 @@ pub fn helper(_: usize) {} pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] { // We used to generate an extra alloca and memcpy for the block's trailing expression value, so // check that we copy directly to the return value slot - // CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0 - // CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1 - // CHECK: ret { ptr, [[USIZE]] } %1 + // CHECK: %0 = insertvalue { ptr[[ADDRSPACE]], [[USIZE]] } poison, ptr[[ADDRSPACE]] %x.0, 0 + // CHECK: %1 = insertvalue { ptr[[ADDRSPACE]], [[USIZE]] } %0, [[USIZE]] %x.1, 1 + // CHECK: ret { ptr[[ADDRSPACE]], [[USIZE]] } %1 { x } } diff --git a/tests/codegen-llvm/align-enum.rs b/tests/codegen-llvm/align-enum.rs index e8dd95d3afb0..6dfb7ba0aa6d 100644 --- a/tests/codegen-llvm/align-enum.rs +++ b/tests/codegen-llvm/align-enum.rs @@ -1,7 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -// #![crate_type = "lib"] +#![no_std] #[repr(align(64))] pub enum Align64 { @@ -19,7 +19,7 @@ pub struct Nested64 { #[no_mangle] pub fn align64(a: u32) -> Align64 { // CHECK: %a64 = alloca [64 x i8], align 64 - // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) + // CHECK: call void @llvm.memcpy.{{.*}}(ptr[[ADDRSPACE]] align 64 %{{.*}}, ptr[[ADDRSPACE]] align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64::A(a); a64 } diff --git a/tests/codegen-llvm/align-fn.rs b/tests/codegen-llvm/align-fn.rs index cbc24e2ae2ea..2165ffddfc58 100644 --- a/tests/codegen-llvm/align-fn.rs +++ b/tests/codegen-llvm/align-fn.rs @@ -3,6 +3,7 @@ //@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![crate_type = "lib"] +#![no_std] // FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity #![feature(rustc_attrs)] #![feature(fn_align)] diff --git a/tests/codegen-llvm/align-offset.rs b/tests/codegen-llvm/align-offset.rs index 21062cc0a914..c64341582be1 100644 --- a/tests/codegen-llvm/align-offset.rs +++ b/tests/codegen-llvm/align-offset.rs @@ -1,6 +1,8 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/70 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @align8 #[no_mangle] @@ -23,7 +25,7 @@ pub fn align_to4(x: &[u8]) -> bool { // CHECK-LABEL: @align_offset_byte_ptr(ptr{{.+}}%ptr) #[no_mangle] pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { - // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE:i[0-9]+]] + // CHECK: %[[ADDR:.+]] = ptrtoint ptr[[ADDRSPACE]] %ptr to [[USIZE:i[0-9]+]] // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[OFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] @@ -40,7 +42,7 @@ pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { // CHECK-LABEL: @align_offset_word_slice(ptr{{.+}}align 4{{.+}}%slice.0 #[no_mangle] pub fn align_offset_word_slice(slice: &[Align4]) -> usize { - // CHECK: %[[ADDR:.+]] = ptrtoint ptr %slice.0 to [[USIZE]] + // CHECK: %[[ADDR:.+]] = ptrtoint ptr[[ADDRSPACE]] %slice.0 to [[USIZE]] // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] @@ -56,7 +58,7 @@ pub fn align_offset_word_slice(slice: &[Align4]) -> usize { // CHECK-LABEL: @align_offset_word_ptr(ptr{{.+}}%ptr #[no_mangle] pub fn align_offset_word_ptr(ptr: *const Align4) -> usize { - // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE]] + // CHECK: %[[ADDR:.+]] = ptrtoint ptr[[ADDRSPACE]] %ptr to [[USIZE]] // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] diff --git a/tests/codegen-llvm/align-static.rs b/tests/codegen-llvm/align-static.rs index 53db998919af..3436b4758c1e 100644 --- a/tests/codegen-llvm/align-static.rs +++ b/tests/codegen-llvm/align-static.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 #![crate_type = "lib"] +#![no_std] #![feature(static_align)] // CHECK: @STATIC_ALIGN = diff --git a/tests/codegen-llvm/align-struct.rs b/tests/codegen-llvm/align-struct.rs index d4cc65e9158c..583dbb688e05 100644 --- a/tests/codegen-llvm/align-struct.rs +++ b/tests/codegen-llvm/align-struct.rs @@ -4,6 +4,7 @@ //@ ignore-i686-pc-windows-gnu #![crate_type = "lib"] +#![no_std] #[repr(align(64))] pub struct Align64(i32); @@ -31,7 +32,7 @@ pub enum Enum64 { #[no_mangle] pub fn align64(i: i32) -> Align64 { // CHECK: %a64 = alloca [64 x i8], align 64 - // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) + // CHECK: call void @llvm.memcpy.{{.*}}(ptr[[ADDRSPACE]] align 64 %{{.*}}, ptr[[ADDRSPACE]] align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64(i); a64 } @@ -41,7 +42,7 @@ pub fn align64(i: i32) -> Align64 { // CHECK-LABEL: @align64_load #[no_mangle] pub fn align64_load(a: Align64) -> i32 { - // CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64 + // CHECK: {{%.*}} = load i32, ptr[[ADDRSPACE]] {{%.*}}, align 64 a.0 } diff --git a/tests/codegen-llvm/alloc-optimisation.rs b/tests/codegen-llvm/alloc-optimisation.rs index 3735860d510f..2fbd821cd514 100644 --- a/tests/codegen-llvm/alloc-optimisation.rs +++ b/tests/codegen-llvm/alloc-optimisation.rs @@ -1,5 +1,11 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/64 + #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::boxed::Box; #[no_mangle] pub fn alloc_test(data: u32) { diff --git a/tests/codegen-llvm/annotate-moves/call-arg-scope.rs b/tests/codegen-llvm/annotate-moves/call-arg-scope.rs index 214e3908609e..d48f28bee183 100644 --- a/tests/codegen-llvm/annotate-moves/call-arg-scope.rs +++ b/tests/codegen-llvm/annotate-moves/call-arg-scope.rs @@ -6,6 +6,7 @@ // NOT have an inlinedAt scope pointing to compiler_move/compiler_copy. #![crate_type = "lib"] +#![no_std] #[derive(Clone, Copy)] pub struct LargeStruct { diff --git a/tests/codegen-llvm/annotate-moves/disabled.rs b/tests/codegen-llvm/annotate-moves/disabled.rs index 2a0e78672318..017dd2dca386 100644 --- a/tests/codegen-llvm/annotate-moves/disabled.rs +++ b/tests/codegen-llvm/annotate-moves/disabled.rs @@ -2,6 +2,7 @@ // Test that move/copy operations are NOT annotated when the flag is disabled #![crate_type = "lib"] +#![no_std] struct LargeStruct { data: [u64; 20], // 160 bytes - would normally trigger annotation diff --git a/tests/codegen-llvm/annotate-moves/integration.rs b/tests/codegen-llvm/annotate-moves/integration.rs index 11b28ac038bc..f102bb0f5295 100644 --- a/tests/codegen-llvm/annotate-moves/integration.rs +++ b/tests/codegen-llvm/annotate-moves/integration.rs @@ -1,6 +1,10 @@ //@ compile-flags: -Z annotate-moves=1 -Copt-level=0 -g #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::string::{String, ToString}; // Test with large array (non-struct type, Copy) type LargeArray = [u64; 20]; // 160 bytes @@ -113,7 +117,7 @@ pub fn test_explicit_copy_assignment() { // CHECK-LABEL: integration::test_array_move pub fn test_array_move() { - let arr: [String; 20] = std::array::from_fn(|i| i.to_string()); + let arr: [String; 20] = core::array::from_fn(|i| i.to_string()); // CHECK: call void @llvm.memcpy{{.*}}, !dbg ![[#ARRAY_MOVE_LOC:]] let _moved = arr; diff --git a/tests/codegen-llvm/annotate-moves/size-limit.rs b/tests/codegen-llvm/annotate-moves/size-limit.rs index 2329c255f497..b9e107a61e16 100644 --- a/tests/codegen-llvm/annotate-moves/size-limit.rs +++ b/tests/codegen-llvm/annotate-moves/size-limit.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Z annotate-moves=100 -Copt-level=0 -g // Test that custom size limits work correctly #![crate_type = "lib"] +#![no_std] struct Struct99 { data: [u8; 99], // just below custom 100-byte threshold diff --git a/tests/codegen-llvm/array-clone.rs b/tests/codegen-llvm/array-clone.rs index 35445174684f..2c60b8a2b559 100644 --- a/tests/codegen-llvm/array-clone.rs +++ b/tests/codegen-llvm/array-clone.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @array_clone #[no_mangle] diff --git a/tests/codegen-llvm/array-cmp.rs b/tests/codegen-llvm/array-cmp.rs index 0d3376554017..49eb09ff6d20 100644 --- a/tests/codegen-llvm/array-cmp.rs +++ b/tests/codegen-llvm/array-cmp.rs @@ -4,6 +4,7 @@ //@ needs-deterministic-layouts (checks depend on tuple layout) #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @compare // CHECK: start: @@ -33,35 +34,35 @@ pub fn array_of_tuple_le(a: &[(i16, u16); 2], b: &[(i16, u16); 2]) -> bool { // *exactly* this IR, but be careful if you ever need to update these checks. // CHECK: start: - // CHECK: %[[A00:.+]] = load i16, ptr %a - // CHECK: %[[B00:.+]] = load i16, ptr %b + // CHECK: %[[A00:.+]] = load i16, ptr[[ADDRSPACE]] %a + // CHECK: %[[B00:.+]] = load i16, ptr[[ADDRSPACE]] %b // CHECK-NOT: cmp // CHECK: %[[EQ00:.+]] = icmp eq i16 %[[A00]], %[[B00]] // CHECK-NEXT: br i1 %[[EQ00]], label %[[L01:.+]], label %[[EXIT_S:.+]] // CHECK: [[L01]]: - // CHECK: %[[PA01:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 2 - // CHECK: %[[PB01:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 2 - // CHECK: %[[A01:.+]] = load i16, ptr %[[PA01]] - // CHECK: %[[B01:.+]] = load i16, ptr %[[PB01]] + // CHECK: %[[PA01:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %a, {{i32|i64}} 2 + // CHECK: %[[PB01:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %b, {{i32|i64}} 2 + // CHECK: %[[A01:.+]] = load i16, ptr[[ADDRSPACE]] %[[PA01]] + // CHECK: %[[B01:.+]] = load i16, ptr[[ADDRSPACE]] %[[PB01]] // CHECK-NOT: cmp // CHECK: %[[EQ01:.+]] = icmp eq i16 %[[A01]], %[[B01]] // CHECK-NEXT: br i1 %[[EQ01]], label %[[L10:.+]], label %[[EXIT_U:.+]] // CHECK: [[L10]]: - // CHECK: %[[PA10:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 4 - // CHECK: %[[PB10:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 4 - // CHECK: %[[A10:.+]] = load i16, ptr %[[PA10]] - // CHECK: %[[B10:.+]] = load i16, ptr %[[PB10]] + // CHECK: %[[PA10:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %a, {{i32|i64}} 4 + // CHECK: %[[PB10:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %b, {{i32|i64}} 4 + // CHECK: %[[A10:.+]] = load i16, ptr[[ADDRSPACE]] %[[PA10]] + // CHECK: %[[B10:.+]] = load i16, ptr[[ADDRSPACE]] %[[PB10]] // CHECK-NOT: cmp // CHECK: %[[EQ10:.+]] = icmp eq i16 %[[A10]], %[[B10]] // CHECK-NEXT: br i1 %[[EQ10]], label %[[L11:.+]], label %[[EXIT_S]] // CHECK: [[L11]]: - // CHECK: %[[PA11:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 6 - // CHECK: %[[PB11:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 6 - // CHECK: %[[A11:.+]] = load i16, ptr %[[PA11]] - // CHECK: %[[B11:.+]] = load i16, ptr %[[PB11]] + // CHECK: %[[PA11:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %a, {{i32|i64}} 6 + // CHECK: %[[PB11:.+]] = getelementptr{{.+}}i8, ptr[[ADDRSPACE]] %b, {{i32|i64}} 6 + // CHECK: %[[A11:.+]] = load i16, ptr[[ADDRSPACE]] %[[PA11]] + // CHECK: %[[B11:.+]] = load i16, ptr[[ADDRSPACE]] %[[PB11]] // CHECK-NOT: cmp // CHECK: %[[EQ11:.+]] = icmp eq i16 %[[A11]], %[[B11]] // CHECK-NEXT: br i1 %[[EQ11]], label %[[DONE:.+]], label %[[EXIT_U]] diff --git a/tests/codegen-llvm/array-codegen.rs b/tests/codegen-llvm/array-codegen.rs index 9b0c6e8c3472..a61a790831e5 100644 --- a/tests/codegen-llvm/array-codegen.rs +++ b/tests/codegen-llvm/array-codegen.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @array_load #[no_mangle] @@ -8,8 +9,8 @@ pub fn array_load(a: &[u8; 4]) -> [u8; 4] { // CHECK-NOT: alloca // CHECK: %[[ALLOCA:.+]] = alloca [4 x i8], align 1 // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %[[ALLOCA]], ptr align 1 %a, {{.+}} 4, i1 false) - // CHECK: %[[TEMP:.+]] = load i32, ptr %[[ALLOCA]], align 1 + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %[[ALLOCA]], ptr[[ADDRSPACE]] align 1 %a, {{.+}} 4, i1 false) + // CHECK: %[[TEMP:.+]] = load i32, ptr[[ADDRSPACE]] %[[ALLOCA]], align 1 // CHECK: ret i32 %[[TEMP]] *a } @@ -22,9 +23,9 @@ pub fn array_store(a: [u8; 4], p: &mut [u8; 4]) { // CHECK-NOT: alloca // CHECK: %a = alloca [4 x i8] // CHECK-NOT: alloca - // store i32 %0, ptr %[[TEMP]] - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %a, ptr [[TEMPALIGN]] %[[TEMP]], {{.+}} 4, i1 false) - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %p, ptr align 1 %a, {{.+}} 4, i1 false) + // store i32 %0, ptr[[ADDRSPACE]] %[[TEMP]] + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %a, ptr[[ADDRSPACE]] [[TEMPALIGN]] %[[TEMP]], {{.+}} 4, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %p, ptr[[ADDRSPACE]] align 1 %a, {{.+}} 4, i1 false) *p = a; } @@ -34,8 +35,8 @@ pub fn array_copy(a: &[u8; 4], p: &mut [u8; 4]) { // CHECK-NOT: alloca // CHECK: %[[LOCAL:.+]] = alloca [4 x i8], align 1 // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %[[LOCAL]], ptr align 1 %a, {{.+}} 4, i1 false) - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %p, ptr align 1 %[[LOCAL]], {{.+}} 4, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %[[LOCAL]], ptr[[ADDRSPACE]] align 1 %a, {{.+}} 4, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %p, ptr[[ADDRSPACE]] align 1 %[[LOCAL]], {{.+}} 4, i1 false) *p = *a; } @@ -45,8 +46,8 @@ pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) { // CHECK-NOT: alloca // CHECK: %[[LOCAL:.+]] = alloca [1 x i8], align 1 // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %[[LOCAL]], ptr align 1 %a, {{.+}} 1, i1 false) - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %p, ptr align 1 %[[LOCAL]], {{.+}} 1, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %[[LOCAL]], ptr[[ADDRSPACE]] align 1 %a, {{.+}} 1, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %p, ptr[[ADDRSPACE]] align 1 %[[LOCAL]], {{.+}} 1, i1 false) *p = *a; } @@ -56,7 +57,7 @@ pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) { // CHECK-NOT: alloca // CHECK: %[[LOCAL:.+]] = alloca [2 x i8], align 1 // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %[[LOCAL]], ptr align 1 %a, {{.+}} 2, i1 false) - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %p, ptr align 1 %[[LOCAL]], {{.+}} 2, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %[[LOCAL]], ptr[[ADDRSPACE]] align 1 %a, {{.+}} 2, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 1 %p, ptr[[ADDRSPACE]] align 1 %[[LOCAL]], {{.+}} 2, i1 false) *p = *a; } diff --git a/tests/codegen-llvm/array-from_fn.rs b/tests/codegen-llvm/array-from_fn.rs index 0a6d5aec4b65..1183a25525a8 100644 --- a/tests/codegen-llvm/array-from_fn.rs +++ b/tests/codegen-llvm/array-from_fn.rs @@ -3,11 +3,12 @@ //@ [OPT] compile-flags: -C opt-level=s -C debuginfo=0 #![crate_type = "lib"] +#![no_std] #![feature(array_from_fn)] #[no_mangle] pub fn iota() -> [u8; 16] { // OPT-NOT: core::array::Guard // NORMAL: core::array::Guard - std::array::from_fn(|i| i as _) + core::array::from_fn(|i| i as _) } diff --git a/tests/codegen-llvm/array-optimized.rs b/tests/codegen-llvm/array-optimized.rs index 000163d5519b..2771a2c03dc1 100644 --- a/tests/codegen-llvm/array-optimized.rs +++ b/tests/codegen-llvm/array-optimized.rs @@ -1,13 +1,14 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @array_copy_1_element #[no_mangle] pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) { // CHECK-NOT: alloca - // CHECK: %[[TEMP:.+]] = load i8, ptr %a, align 1 - // CHECK: store i8 %[[TEMP]], ptr %p, align 1 + // CHECK: %[[TEMP:.+]] = load i8, ptr[[ADDRSPACE]] %a, align 1 + // CHECK: store i8 %[[TEMP]], ptr[[ADDRSPACE]] %p, align 1 // CHECK: ret *p = *a; } @@ -16,8 +17,8 @@ pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) { #[no_mangle] pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) { // CHECK-NOT: alloca - // CHECK: %[[TEMP:.+]] = load i16, ptr %a, align 1 - // CHECK: store i16 %[[TEMP]], ptr %p, align 1 + // CHECK: %[[TEMP:.+]] = load i16, ptr[[ADDRSPACE]] %a, align 1 + // CHECK: store i16 %[[TEMP]], ptr[[ADDRSPACE]] %p, align 1 // CHECK: ret *p = *a; } @@ -26,8 +27,8 @@ pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) { #[no_mangle] pub fn array_copy_4_elements(a: &[u8; 4], p: &mut [u8; 4]) { // CHECK-NOT: alloca - // CHECK: %[[TEMP:.+]] = load i32, ptr %a, align 1 - // CHECK: store i32 %[[TEMP]], ptr %p, align 1 + // CHECK: %[[TEMP:.+]] = load i32, ptr[[ADDRSPACE]] %a, align 1 + // CHECK: store i32 %[[TEMP]], ptr[[ADDRSPACE]] %p, align 1 // CHECK: ret *p = *a; } diff --git a/tests/codegen-llvm/array-repeat.rs b/tests/codegen-llvm/array-repeat.rs index 1c45341d764c..a7b6ce36cda8 100644 --- a/tests/codegen-llvm/array-repeat.rs +++ b/tests/codegen-llvm/array-repeat.rs @@ -1,8 +1,9 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] -use std::array::repeat; +use core::array::repeat; // CHECK-LABEL: @byte_repeat #[no_mangle] diff --git a/tests/codegen-llvm/ascii-char.rs b/tests/codegen-llvm/ascii-char.rs index 86ec9d73afea..2bac6e2c70c9 100644 --- a/tests/codegen-llvm/ascii-char.rs +++ b/tests/codegen-llvm/ascii-char.rs @@ -1,9 +1,10 @@ //@ compile-flags: -C opt-level=1 #![crate_type = "lib"] +#![no_std] #![feature(ascii_char)] -use std::ascii::Char as AsciiChar; +use core::ascii::Char as AsciiChar; // CHECK-LABEL: i8 @unwrap_digit_from_remainder(i32 #[no_mangle] diff --git a/tests/codegen-llvm/atomic-operations.rs b/tests/codegen-llvm/atomic-operations.rs index 8771b8b24199..a3f5285f71f1 100644 --- a/tests/codegen-llvm/atomic-operations.rs +++ b/tests/codegen-llvm/atomic-operations.rs @@ -1,44 +1,46 @@ // Code generation of atomic operations. //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/73 #![crate_type = "lib"] +#![no_std] -use std::sync::atomic::AtomicI32; -use std::sync::atomic::Ordering::*; +use core::sync::atomic::AtomicI32; +use core::sync::atomic::Ordering::*; // CHECK-LABEL: @compare_exchange #[no_mangle] pub fn compare_exchange(a: &AtomicI32) { - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 10 monotonic monotonic - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 11 monotonic acquire - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 12 monotonic seq_cst + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 10 monotonic monotonic + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 11 monotonic acquire + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 12 monotonic seq_cst let _ = a.compare_exchange(0, 10, Relaxed, Relaxed); let _ = a.compare_exchange(0, 11, Relaxed, Acquire); let _ = a.compare_exchange(0, 12, Relaxed, SeqCst); - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 20 release monotonic - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 21 release acquire - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 22 release seq_cst + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 20 release monotonic + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 21 release acquire + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 22 release seq_cst let _ = a.compare_exchange(0, 20, Release, Relaxed); let _ = a.compare_exchange(0, 21, Release, Acquire); let _ = a.compare_exchange(0, 22, Release, SeqCst); - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 30 acquire monotonic - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 31 acquire acquire - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 32 acquire seq_cst + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 30 acquire monotonic + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 31 acquire acquire + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 32 acquire seq_cst let _ = a.compare_exchange(0, 30, Acquire, Relaxed); let _ = a.compare_exchange(0, 31, Acquire, Acquire); let _ = a.compare_exchange(0, 32, Acquire, SeqCst); - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 40 acq_rel monotonic - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 41 acq_rel acquire - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 42 acq_rel seq_cst + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 40 acq_rel monotonic + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 41 acq_rel acquire + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 42 acq_rel seq_cst let _ = a.compare_exchange(0, 40, AcqRel, Relaxed); let _ = a.compare_exchange(0, 41, AcqRel, Acquire); let _ = a.compare_exchange(0, 42, AcqRel, SeqCst); - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 50 seq_cst monotonic - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 51 seq_cst acquire - // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 52 seq_cst seq_cst + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 50 seq_cst monotonic + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 51 seq_cst acquire + // CHECK: cmpxchg ptr[[ADDRSPACE]] %{{.*}}, i32 0, i32 52 seq_cst seq_cst let _ = a.compare_exchange(0, 50, SeqCst, Relaxed); let _ = a.compare_exchange(0, 51, SeqCst, Acquire); let _ = a.compare_exchange(0, 52, SeqCst, SeqCst); @@ -47,37 +49,37 @@ pub fn compare_exchange(a: &AtomicI32) { // CHECK-LABEL: @compare_exchange_weak #[no_mangle] pub fn compare_exchange_weak(w: &AtomicI32) { - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 10 monotonic monotonic - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 11 monotonic acquire - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 12 monotonic seq_cst + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 10 monotonic monotonic + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 11 monotonic acquire + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 12 monotonic seq_cst let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed); let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire); let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst); - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 20 release monotonic - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 21 release acquire - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 22 release seq_cst + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 20 release monotonic + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 21 release acquire + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 22 release seq_cst let _ = w.compare_exchange_weak(1, 20, Release, Relaxed); let _ = w.compare_exchange_weak(1, 21, Release, Acquire); let _ = w.compare_exchange_weak(1, 22, Release, SeqCst); - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 30 acquire monotonic - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 31 acquire acquire - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 32 acquire seq_cst + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 30 acquire monotonic + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 31 acquire acquire + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 32 acquire seq_cst let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed); let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire); let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst); - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 40 acq_rel monotonic - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 41 acq_rel acquire - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 42 acq_rel seq_cst + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 40 acq_rel monotonic + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 41 acq_rel acquire + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 42 acq_rel seq_cst let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed); let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire); let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst); - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 50 seq_cst monotonic - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 51 seq_cst acquire - // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 52 seq_cst seq_cst + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 50 seq_cst monotonic + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 51 seq_cst acquire + // CHECK: cmpxchg weak ptr[[ADDRSPACE]] %{{.*}}, i32 1, i32 52 seq_cst seq_cst let _ = w.compare_exchange_weak(1, 50, SeqCst, Relaxed); let _ = w.compare_exchange_weak(1, 51, SeqCst, Acquire); let _ = w.compare_exchange_weak(1, 52, SeqCst, SeqCst); diff --git a/tests/codegen-llvm/atomicptr.rs b/tests/codegen-llvm/atomicptr.rs index 9d5e618fe76f..81dedcbea3bb 100644 --- a/tests/codegen-llvm/atomicptr.rs +++ b/tests/codegen-llvm/atomicptr.rs @@ -5,14 +5,16 @@ // arguments to `atomicrmw xchg`. //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/74 #![crate_type = "lib"] +#![no_std] -use std::ptr::without_provenance_mut; -use std::sync::atomic::AtomicPtr; -use std::sync::atomic::Ordering::Relaxed; +use core::ptr::without_provenance_mut; +use core::sync::atomic::AtomicPtr; +use core::sync::atomic::Ordering::Relaxed; // Portability hack so that we can say [[USIZE]] instead of i64/i32/i16 for usize. -// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] #[no_mangle] pub fn helper(_: usize) {} @@ -20,8 +22,8 @@ pub fn helper(_: usize) {} #[no_mangle] pub fn atomicptr_fetch_byte_add(a: &AtomicPtr, v: usize) -> *mut u8 { // CHECK: llvm.lifetime.start - // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr %{{.*}}, [[USIZE]] %v - // CHECK-NEXT: inttoptr [[USIZE]] %[[RET]] to ptr + // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr[[ADDRSPACE]] %{{.*}}, [[USIZE]] %v + // CHECK-NEXT: inttoptr [[USIZE]] %[[RET]] to ptr[[ADDRSPACE]] a.fetch_byte_add(v, Relaxed) } @@ -29,7 +31,7 @@ pub fn atomicptr_fetch_byte_add(a: &AtomicPtr, v: usize) -> *mut u8 { #[no_mangle] pub fn atomicptr_swap(a: &AtomicPtr, ptr: *mut u8) -> *mut u8 { // CHECK-NOT: ptrtoint - // CHECK: atomicrmw xchg ptr %{{.*}}, ptr %{{.*}} monotonic + // CHECK: atomicrmw xchg ptr[[ADDRSPACE]] %{{.*}}, ptr[[ADDRSPACE]] %{{.*}} monotonic // CHECK-NOT: inttoptr a.swap(ptr, Relaxed) } diff --git a/tests/codegen-llvm/become-musttail.rs b/tests/codegen-llvm/become-musttail.rs index 07f335719104..1638b5b29f53 100644 --- a/tests/codegen-llvm/become-musttail.rs +++ b/tests/codegen-llvm/become-musttail.rs @@ -2,6 +2,7 @@ //@ needs-unwind #![crate_type = "lib"] +#![no_std] #![feature(explicit_tail_calls)] // CHECK-LABEL: define {{.*}}@fibonacci( diff --git a/tests/codegen-llvm/bigint-helpers.rs b/tests/codegen-llvm/bigint-helpers.rs index ec70a3eabedb..5052a6484271 100644 --- a/tests/codegen-llvm/bigint-helpers.rs +++ b/tests/codegen-llvm/bigint-helpers.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C opt-level=3 #![crate_type = "lib"] +#![no_std] #![feature(bigint_helper_methods)] // Note that there's also an assembly test for this, which is what checks for diff --git a/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs index 3d3a0f91c3e6..e5c1667e3a1e 100644 --- a/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs +++ b/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs @@ -1,8 +1,11 @@ //@ compile-flags: -Copt-level=3 --crate-name=test //@ ignore-std-debug-assertions #![crate_type = "lib"] +#![no_std] -use std::collections::binary_heap::PeekMut; +extern crate alloc; + +use alloc::collections::binary_heap::PeekMut; // CHECK-LABEL: @peek_mut_pop #[no_mangle] diff --git a/tests/codegen-llvm/binary-search-index-no-bound-check.rs b/tests/codegen-llvm/binary-search-index-no-bound-check.rs index 8322c4179bd1..c516ba47307a 100644 --- a/tests/codegen-llvm/binary-search-index-no-bound-check.rs +++ b/tests/codegen-llvm/binary-search-index-no-bound-check.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // Make sure no bounds checks are emitted when slicing or indexing // with an index from `binary_search`. diff --git a/tests/codegen-llvm/bool-cmp.rs b/tests/codegen-llvm/bool-cmp.rs index 71d3411689f4..35bbf8160d04 100644 --- a/tests/codegen-llvm/bool-cmp.rs +++ b/tests/codegen-llvm/bool-cmp.rs @@ -4,8 +4,9 @@ //@ compile-flags: -C opt-level=3 #![crate_type = "lib"] +#![no_std] -use std::cmp::Ordering; +use core::cmp::Ordering; // CHECK-LABEL: @cmp_bool #[no_mangle] diff --git a/tests/codegen-llvm/bounds-check-elision-slice-min.rs b/tests/codegen-llvm/bounds-check-elision-slice-min.rs index e160e5da50f9..0ef4c7fc23f5 100644 --- a/tests/codegen-llvm/bounds-check-elision-slice-min.rs +++ b/tests/codegen-llvm/bounds-check-elision-slice-min.rs @@ -6,6 +6,7 @@ //@ compile-flags: -C opt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @foo // CHECK-NOT: panic_bounds_check diff --git a/tests/codegen-llvm/bounds-checking/gep-issue-133979.rs b/tests/codegen-llvm/bounds-checking/gep-issue-133979.rs index 876bdbfb0e14..97466ba6cf50 100644 --- a/tests/codegen-llvm/bounds-checking/gep-issue-133979.rs +++ b/tests/codegen-llvm/bounds-checking/gep-issue-133979.rs @@ -4,6 +4,7 @@ //@ compile-flags: -Copt-level=2 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @test( #[no_mangle] diff --git a/tests/codegen-llvm/box-default-debug-copies.rs b/tests/codegen-llvm/box-default-debug-copies.rs index 06cc41b21c06..7cd71e0168c2 100644 --- a/tests/codegen-llvm/box-default-debug-copies.rs +++ b/tests/codegen-llvm/box-default-debug-copies.rs @@ -10,6 +10,10 @@ // of checking for exactly two. #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::boxed::Box; #[allow(dead_code)] pub struct Thing([u8; 1000000]); diff --git a/tests/codegen-llvm/box-uninit-bytes.rs b/tests/codegen-llvm/box-uninit-bytes.rs index 0cc011485951..12c76ad8e5f7 100644 --- a/tests/codegen-llvm/box-uninit-bytes.rs +++ b/tests/codegen-llvm/box-uninit-bytes.rs @@ -1,7 +1,10 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] -use std::mem::MaybeUninit; +use core::mem::MaybeUninit; +extern crate alloc; +use alloc::boxed::Box; // Boxing a `MaybeUninit` value should not copy junk from the stack #[no_mangle] @@ -40,7 +43,8 @@ pub fn box_lotsa_padding() -> Box { } // Hide the `allocalign` attribute in the declaration of __rust_alloc +// // from the CHECK-NOT above, and also verify the attributes got set reasonably. -// CHECK: declare {{(dso_local )?}}noalias noundef ptr @{{.*}}__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] +// CHECK: declare {{(dso_local )?}}noalias noundef ptr[[ADDRSPACE]] @{{.*}}__rust_alloc(i{{[0-9]+}} noundef{{( signext)?}}, i{{[0-9]+}} allocalign noundef{{( signext)?}}) unnamed_addr[[ADDRSPACE]] [[RUST_ALLOC_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) {{(uwtable )?}}"alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen-llvm/c-variadic-lifetime.rs b/tests/codegen-llvm/c-variadic-lifetime.rs index fa38fbbc5381..05a3399f66f6 100644 --- a/tests/codegen-llvm/c-variadic-lifetime.rs +++ b/tests/codegen-llvm/c-variadic-lifetime.rs @@ -2,20 +2,21 @@ //@ compile-flags: -Copt-level=3 #![feature(c_variadic)] #![crate_type = "lib"] +#![no_std] // Check that `%args` explicitly has its lifetime start and end. Being explicit can improve // instruction and register selection, see e.g. https://github.com/rust-lang/rust/pull/144549 #[unsafe(no_mangle)] unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 { - // CHECK: call void @llvm.lifetime.start.p0({{(i64 [0-9]+, )?}}ptr nonnull %args) - // CHECK: call void @llvm.va_start.p0(ptr nonnull %args) + // CHECK: call void @llvm.lifetime.start.[[PSPACE:p[0-9]+]]({{(i64 [0-9]+, )?}}ptr[[ADDRSPACE]] nonnull %args) + // CHECK: call void @llvm.va_start.[[PSPACE]](ptr[[ADDRSPACE]] nonnull %args) let b = args.arg::(); let c = args.arg::(); a + b + c - // CHECK: call void @llvm.va_end.p0(ptr nonnull %args) - // CHECK: call void @llvm.lifetime.end.p0({{(i64 [0-9]+, )?}}ptr nonnull %args) + // CHECK: call void @llvm.va_end.[[PSPACE]](ptr[[ADDRSPACE]] nonnull %args) + // CHECK: call void @llvm.lifetime.end.[[PSPACE]]({{(i64 [0-9]+, )?}}ptr[[ADDRSPACE]] nonnull %args) } diff --git a/tests/codegen-llvm/call-llvm-intrinsics.rs b/tests/codegen-llvm/call-llvm-intrinsics.rs index dc7e0249cb6a..06a427410107 100644 --- a/tests/codegen-llvm/call-llvm-intrinsics.rs +++ b/tests/codegen-llvm/call-llvm-intrinsics.rs @@ -5,12 +5,13 @@ #![feature(link_llvm_intrinsics)] #![crate_type = "lib"] +#![no_std] struct A; impl Drop for A { fn drop(&mut self) { - println!("A"); + core::hint::black_box(()) } } diff --git a/tests/codegen-llvm/cast-optimized.rs b/tests/codegen-llvm/cast-optimized.rs index 11220c4a922b..c10346e3fd7c 100644 --- a/tests/codegen-llvm/cast-optimized.rs +++ b/tests/codegen-llvm/cast-optimized.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] +#![no_std] // This tests that LLVM can optimize based on the niches in the source or // destination types for casts. diff --git a/tests/codegen-llvm/cffi/ffi-const.rs b/tests/codegen-llvm/cffi/ffi-const.rs index 3ea9d517ec25..4b92407e9aad 100644 --- a/tests/codegen-llvm/cffi/ffi-const.rs +++ b/tests/codegen-llvm/cffi/ffi-const.rs @@ -1,5 +1,6 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] #![feature(ffi_const)] pub fn bar() { diff --git a/tests/codegen-llvm/cffi/ffi-pure.rs b/tests/codegen-llvm/cffi/ffi-pure.rs index a61e80ecf652..fa2cd73ccca8 100644 --- a/tests/codegen-llvm/cffi/ffi-pure.rs +++ b/tests/codegen-llvm/cffi/ffi-pure.rs @@ -1,5 +1,6 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] #![feature(ffi_pure)] pub fn bar() { diff --git a/tests/codegen-llvm/cfguard-non-msvc.rs b/tests/codegen-llvm/cfguard-non-msvc.rs index 1e6559aaf5d2..fb94193a4ff9 100644 --- a/tests/codegen-llvm/cfguard-non-msvc.rs +++ b/tests/codegen-llvm/cfguard-non-msvc.rs @@ -2,6 +2,7 @@ //@ ignore-msvc #![crate_type = "lib"] +#![no_std] // A basic test function. pub fn test() {} diff --git a/tests/codegen-llvm/char-ascii-branchless.rs b/tests/codegen-llvm/char-ascii-branchless.rs index 2cd5b5135a40..05f7a94303fe 100644 --- a/tests/codegen-llvm/char-ascii-branchless.rs +++ b/tests/codegen-llvm/char-ascii-branchless.rs @@ -3,6 +3,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @is_ascii_alphanumeric_char #[no_mangle] diff --git a/tests/codegen-llvm/char-escape-debug-no-bounds-check.rs b/tests/codegen-llvm/char-escape-debug-no-bounds-check.rs index cfde46045e5a..5b71836a21da 100644 --- a/tests/codegen-llvm/char-escape-debug-no-bounds-check.rs +++ b/tests/codegen-llvm/char-escape-debug-no-bounds-check.rs @@ -1,7 +1,8 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] -use std::char::EscapeDebug; +use core::char::EscapeDebug; // Make sure no bounds checks are emitted when escaping a character. diff --git a/tests/codegen-llvm/checked_ilog.rs b/tests/codegen-llvm/checked_ilog.rs index e340a45b6a96..b6de2943c684 100644 --- a/tests/codegen-llvm/checked_ilog.rs +++ b/tests/codegen-llvm/checked_ilog.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // Ensure that when val < base, we do not divide or multiply. diff --git a/tests/codegen-llvm/checked_math.rs b/tests/codegen-llvm/checked_math.rs index f24d9f24dcb2..d42f53624ca2 100644 --- a/tests/codegen-llvm/checked_math.rs +++ b/tests/codegen-llvm/checked_math.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] +#![no_std] // Because the result of something like `u32::checked_sub` can only be used if it // didn't overflow, make sure that LLVM actually knows that in optimized builds. diff --git a/tests/codegen-llvm/clone-shims.rs b/tests/codegen-llvm/clone-shims.rs index 06c959f9ee7d..bde191124d39 100644 --- a/tests/codegen-llvm/clone-shims.rs +++ b/tests/codegen-llvm/clone-shims.rs @@ -4,6 +4,7 @@ //@ compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0 -Zinline-mir=no #![crate_type = "lib"] +#![no_std] pub type Test = (i32, i32, *const i32); pub static TEST: fn(&Test) -> Test = ::clone; diff --git a/tests/codegen-llvm/clone_as_copy.rs b/tests/codegen-llvm/clone_as_copy.rs index ef834ef59120..3d74335cb59d 100644 --- a/tests/codegen-llvm/clone_as_copy.rs +++ b/tests/codegen-llvm/clone_as_copy.rs @@ -6,6 +6,7 @@ // Ensure that we only generate a memcpy instruction. #![crate_type = "lib"] +#![no_std] #[derive(Clone)] struct SubCloneAndCopy { diff --git a/tests/codegen-llvm/coercions.rs b/tests/codegen-llvm/coercions.rs index 63c1742c6399..b8868532d777 100644 --- a/tests/codegen-llvm/coercions.rs +++ b/tests/codegen-llvm/coercions.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] static X: i32 = 5; diff --git a/tests/codegen-llvm/cold-attribute.rs b/tests/codegen-llvm/cold-attribute.rs index fd8b3dbea2ae..3304957536fb 100644 --- a/tests/codegen-llvm/cold-attribute.rs +++ b/tests/codegen-llvm/cold-attribute.rs @@ -6,6 +6,7 @@ //@ compile-flags: -Copt-level=0 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: ; cold_attribute::free_function // CHECK-NEXT: Function Attrs: cold {{.*}} diff --git a/tests/codegen-llvm/cold-call-declare-and-call.rs b/tests/codegen-llvm/cold-call-declare-and-call.rs index b18565ee6c3b..cb1bbb9f0274 100644 --- a/tests/codegen-llvm/cold-call-declare-and-call.rs +++ b/tests/codegen-llvm/cold-call-declare-and-call.rs @@ -5,6 +5,7 @@ //@[WIN] only-x86_64 #![crate_type = "lib"] +#![no_std] #![feature(rust_cold_cc)] // wasm marks the definition as `dso_local`, so allow that as optional. diff --git a/tests/codegen-llvm/common_prim_int_ptr.rs b/tests/codegen-llvm/common_prim_int_ptr.rs index 2c906e86bd73..f68f2b48f628 100644 --- a/tests/codegen-llvm/common_prim_int_ptr.rs +++ b/tests/codegen-llvm/common_prim_int_ptr.rs @@ -1,7 +1,12 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: CHERIoT-Platform/cheri-rust/issues/71 #![crate_type = "lib"] #![feature(core_intrinsics)] +#![no_std] + +extern crate alloc; +use alloc::boxed::Box; // Tests that codegen works properly when enums like `Result>` // are represented as `{ u64, ptr }`, i.e., for `Ok(123)`, `123` is stored @@ -11,9 +16,9 @@ #[no_mangle] pub fn insert_int(x: usize) -> Result> { // CHECK: start: - // CHECK-NEXT: %[[WO_PROV:.+]] = inttoptr [[USIZE:i[0-9]+]] %x to ptr - // CHECK-NEXT: %[[R:.+]] = insertvalue { [[USIZE]], ptr } { [[USIZE]] 0, ptr poison }, ptr %[[WO_PROV]], 1 - // CHECK-NEXT: ret { [[USIZE]], ptr } %[[R]] + // CHECK-NEXT: %[[WO_PROV:.+]] = inttoptr [[USIZE:i[0-9]+]] %x to ptr[[ADDRSPACE]] + // CHECK-NEXT: %[[R:.+]] = insertvalue { [[USIZE]], ptr[[ADDRSPACE]] } { [[USIZE]] 0, ptr[[ADDRSPACE]] poison }, ptr %[[WO_PROV]], 1 + // CHECK-NEXT: ret { [[USIZE]], ptr[[ADDRSPACE]] } %[[R]] Ok(x) } @@ -31,11 +36,11 @@ pub fn insert_box(x: Box<()>) -> Result> { // CHECK-SAME: (i{{[0-9]+}} {{[^%]+}} [[DISCRIMINANT:%[0-9]+]], ptr {{[^,]+}} [[PAYLOAD:%[0-9]+]]) #[no_mangle] pub unsafe fn extract_int(x: Result>) -> usize { - // CHECK: [[TEMP:%.+]] = ptrtoint ptr [[PAYLOAD]] to [[USIZE:i[0-9]+]] + // CHECK: [[TEMP:%.+]] = ptrtoint ptr[[ADDRSPACE]] [[PAYLOAD]] to [[USIZE:i[0-9]+]] // CHECK: ret [[USIZE]] [[TEMP]] match x { Ok(v) => v, - Err(_) => std::intrinsics::unreachable(), + Err(_) => core::intrinsics::unreachable(), } } @@ -43,9 +48,9 @@ pub unsafe fn extract_int(x: Result>) -> usize { // CHECK-SAME: (i{{[0-9]+}} {{[^%]+}} [[DISCRIMINANT:%[0-9]+]], ptr {{[^%]+}} [[PAYLOAD:%[0-9]+]]) #[no_mangle] pub unsafe fn extract_box(x: Result>) -> Box { - // CHECK: ret ptr [[PAYLOAD]] + // CHECK: ret ptr[[ADDRSPACE]] [[PAYLOAD]] match x { - Ok(_) => std::intrinsics::unreachable(), + Ok(_) => core::intrinsics::unreachable(), Err(e) => e, } } diff --git a/tests/codegen-llvm/comparison-operators-2-struct.rs b/tests/codegen-llvm/comparison-operators-2-struct.rs index d44f92f511b6..9cca1cd84fc8 100644 --- a/tests/codegen-llvm/comparison-operators-2-struct.rs +++ b/tests/codegen-llvm/comparison-operators-2-struct.rs @@ -5,14 +5,15 @@ // in the operators for such a type all optimize away. #![crate_type = "lib"] +#![no_std] -use std::cmp::Ordering; +use core::cmp::Ordering; #[derive(PartialOrd, PartialEq)] pub struct Foo(i32, u32); // CHECK-LABEL: @check_lt( -// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:[0-9]+]]) #[no_mangle] pub fn check_lt(a: Foo, b: Foo) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] @@ -24,7 +25,7 @@ pub fn check_lt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_le( -// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:[0-9]+]]) #[no_mangle] pub fn check_le(a: Foo, b: Foo) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] @@ -36,7 +37,7 @@ pub fn check_le(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_gt( -// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:[0-9]+]]) #[no_mangle] pub fn check_gt(a: Foo, b: Foo) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] @@ -48,7 +49,7 @@ pub fn check_gt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_ge( -// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:[0-9]+]]) #[no_mangle] pub fn check_ge(a: Foo, b: Foo) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] diff --git a/tests/codegen-llvm/comparison-operators-2-tuple.rs b/tests/codegen-llvm/comparison-operators-2-tuple.rs index 37a7c5dfdaf0..91e39f0f431e 100644 --- a/tests/codegen-llvm/comparison-operators-2-tuple.rs +++ b/tests/codegen-llvm/comparison-operators-2-tuple.rs @@ -1,8 +1,9 @@ //@ compile-flags: -C opt-level=1 -Z merge-functions=disabled #![crate_type = "lib"] +#![no_std] -use std::cmp::Ordering; +use core::cmp::Ordering; type TwoTuple = (i16, u16); @@ -16,7 +17,7 @@ type TwoTuple = (i16, u16); // // CHECK-LABEL: @check_lt_direct -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -28,7 +29,7 @@ pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_le_direct -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -40,7 +41,7 @@ pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_gt_direct -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -52,7 +53,7 @@ pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_ge_direct -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_ge_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -68,7 +69,7 @@ pub fn check_ge_direct(a: TwoTuple, b: TwoTuple) -> bool { // // CHECK-LABEL: @check_lt_via_cmp -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_lt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -80,7 +81,7 @@ pub fn check_lt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_le_via_cmp -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_le_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -92,7 +93,7 @@ pub fn check_le_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_gt_via_cmp -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_gt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] @@ -104,7 +105,7 @@ pub fn check_gt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { } // CHECK-LABEL: @check_ge_via_cmp -// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) +// CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:[0-9]+]]) #[no_mangle] pub fn check_ge_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] diff --git a/tests/codegen-llvm/comparison-operators-newtype.rs b/tests/codegen-llvm/comparison-operators-newtype.rs index acce0cb59467..52cd9d321bdf 100644 --- a/tests/codegen-llvm/comparison-operators-newtype.rs +++ b/tests/codegen-llvm/comparison-operators-newtype.rs @@ -5,14 +5,15 @@ //@ compile-flags: -C opt-level=1 #![crate_type = "lib"] +#![no_std] -use std::cmp::Ordering; +use core::cmp::Ordering; #[derive(PartialOrd, PartialEq)] pub struct Foo(u16); // CHECK-LABEL: @check_lt -// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:.+]]) +// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:[0-9]+]]) #[no_mangle] pub fn check_lt(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ult i16 %[[A]], %[[B]] @@ -21,7 +22,7 @@ pub fn check_lt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_le -// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:.+]]) +// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:[0-9]+]]) #[no_mangle] pub fn check_le(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ule i16 %[[A]], %[[B]] @@ -30,7 +31,7 @@ pub fn check_le(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_gt -// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:.+]]) +// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:[0-9]+]]) #[no_mangle] pub fn check_gt(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ugt i16 %[[A]], %[[B]] @@ -39,7 +40,7 @@ pub fn check_gt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_ge -// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:.+]]) +// CHECK-SAME: (i16{{.*}} %[[A:.+]], i16{{.*}} %[[B:[0-9]+]]) #[no_mangle] pub fn check_ge(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp uge i16 %[[A]], %[[B]] diff --git a/tests/codegen-llvm/const-array.rs b/tests/codegen-llvm/const-array.rs index b3df76c3d8e0..08395905c657 100644 --- a/tests/codegen-llvm/const-array.rs +++ b/tests/codegen-llvm/const-array.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] const LUT: [u8; 4] = [1, 1, 1, 1]; diff --git a/tests/codegen-llvm/const-vector.rs b/tests/codegen-llvm/const-vector.rs index f43074923411..cdabf784bbc8 100644 --- a/tests/codegen-llvm/const-vector.rs +++ b/tests/codegen-llvm/const-vector.rs @@ -3,10 +3,12 @@ //@ [OPT0_S390X] only-s390x //@ [OPT0] compile-flags: -C no-prepopulate-passes -Copt-level=0 //@ [OPT0_S390X] compile-flags: -C no-prepopulate-passes -Copt-level=0 -C target-cpu=z13 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME CHERIoT-Platform/cheri-rust/issues/72 // This test checks that constants of SIMD type are passed as immediate vectors. // We ensure that both vector representations (struct with fields and struct wrapping array) work. #![crate_type = "lib"] +#![no_std] #![feature(abi_unadjusted)] #![feature(const_trait_impl)] #![feature(repr_simd)] diff --git a/tests/codegen-llvm/const_scalar_pair.rs b/tests/codegen-llvm/const_scalar_pair.rs index f142896c31f1..0814f2630159 100644 --- a/tests/codegen-llvm/const_scalar_pair.rs +++ b/tests/codegen-llvm/const_scalar_pair.rs @@ -1,5 +1,7 @@ //@ compile-flags: --crate-type=lib -Copt-level=0 -Zmir-opt-level=0 -C debuginfo=2 +#![no_std] + // Test that we don't generate a memory allocation for the constant // and read the fields from that, but instead just create the value pair directly. pub fn foo() -> (i32, i32) { diff --git a/tests/codegen-llvm/constant-branch.rs b/tests/codegen-llvm/constant-branch.rs index 8fc8fb4f57a2..b90101f4b81d 100644 --- a/tests/codegen-llvm/constant-branch.rs +++ b/tests/codegen-llvm/constant-branch.rs @@ -3,6 +3,7 @@ // branch or a switch #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @if_bool #[no_mangle] diff --git a/tests/codegen-llvm/consts.rs b/tests/codegen-llvm/consts.rs index 42ce7679d1ac..6c4d573ea9b6 100644 --- a/tests/codegen-llvm/consts.rs +++ b/tests/codegen-llvm/consts.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] // Below, these constants are defined as enum variants that by itself would // have a lower alignment than the enum type. Ensure that we mark them @@ -42,7 +43,7 @@ pub fn inline_enum_const() -> E { #[no_mangle] pub fn low_align_const() -> E { // Check that low_align_const and high_align_const use the same constant - // CHECK: memcpy.{{.+}}(ptr align 2 %_0, ptr align 2 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) + // CHECK: memcpy.{{.+}}(ptr[[ADDRSPACE]] align 2 %_0, ptr[[ADDRSPACE]] align 2 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) *&E::A(0) } @@ -50,6 +51,6 @@ pub fn low_align_const() -> E { #[no_mangle] pub fn high_align_const() -> E { // Check that low_align_const and high_align_const use the same constant - // CHECK: memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) + // CHECK: memcpy.{{.+}}(ptr[[ADDRSPACE]] align 4 %_0, ptr[[ADDRSPACE]] align 4 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false) *&E::A(0) } diff --git a/tests/codegen-llvm/enum/enum-aggregate.rs b/tests/codegen-llvm/enum/enum-aggregate.rs index 89517008c637..5eb203cbaeda 100644 --- a/tests/codegen-llvm/enum/enum-aggregate.rs +++ b/tests/codegen-llvm/enum/enum-aggregate.rs @@ -1,11 +1,13 @@ //@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] +#![no_std] -use std::cmp::Ordering; -use std::num::NonZero; -use std::ptr::NonNull; +use core::cmp::Ordering; +use core::num::NonZero; +use core::ptr::NonNull; #[no_mangle] fn make_some_bool(x: bool) -> Option { diff --git a/tests/codegen-llvm/enum/enum-bounds-check-derived-idx.rs b/tests/codegen-llvm/enum/enum-bounds-check-derived-idx.rs index a5785f4addf0..64c257eb3d38 100644 --- a/tests/codegen-llvm/enum/enum-bounds-check-derived-idx.rs +++ b/tests/codegen-llvm/enum/enum-bounds-check-derived-idx.rs @@ -3,6 +3,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] pub enum Bar { A = 1, diff --git a/tests/codegen-llvm/enum/enum-bounds-check-issue-13926.rs b/tests/codegen-llvm/enum/enum-bounds-check-issue-13926.rs index 6e8e5035b0d0..6f049c109256 100644 --- a/tests/codegen-llvm/enum/enum-bounds-check-issue-13926.rs +++ b/tests/codegen-llvm/enum/enum-bounds-check-issue-13926.rs @@ -3,6 +3,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] #[repr(u8)] pub enum Exception { diff --git a/tests/codegen-llvm/enum/enum-bounds-check-issue-82871.rs b/tests/codegen-llvm/enum/enum-bounds-check-issue-82871.rs index 3b8a146838aa..bcc001535ca8 100644 --- a/tests/codegen-llvm/enum/enum-bounds-check-issue-82871.rs +++ b/tests/codegen-llvm/enum/enum-bounds-check-issue-82871.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C opt-level=0 #![crate_type = "lib"] +#![no_std] #[repr(C)] pub enum E { diff --git a/tests/codegen-llvm/enum/enum-bounds-check.rs b/tests/codegen-llvm/enum/enum-bounds-check.rs index 5362598ca7c4..b9a21c97cfa9 100644 --- a/tests/codegen-llvm/enum/enum-bounds-check.rs +++ b/tests/codegen-llvm/enum/enum-bounds-check.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] pub enum Foo { A, diff --git a/tests/codegen-llvm/enum/enum-discriminant-eq.rs b/tests/codegen-llvm/enum/enum-discriminant-eq.rs index 68cd58643e84..76673b177f03 100644 --- a/tests/codegen-llvm/enum/enum-discriminant-eq.rs +++ b/tests/codegen-llvm/enum/enum-discriminant-eq.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize //@ revisions: LLVM20 LLVM21 //@ [LLVM21] min-llvm-version: 21 //@ [LLVM20] max-llvm-major-version: 20 @@ -8,14 +9,15 @@ // so make sure we emit that in some reasonable way. #![crate_type = "lib"] +#![no_std] #![feature(ascii_char)] #![feature(core_intrinsics)] #![feature(repr128)] -use std::ascii::Char as AC; -use std::cmp::Ordering; -use std::intrinsics::discriminant_value; -use std::num::NonZero; +use core::ascii::Char as AC; +use core::cmp::Ordering; +use core::intrinsics::discriminant_value; +use core::num::NonZero; // A type that's bigger than `isize`, unlike the usual cases that have small tags. #[repr(u128)] diff --git a/tests/codegen-llvm/enum/enum-early-otherwise-branch.rs b/tests/codegen-llvm/enum/enum-early-otherwise-branch.rs index 4cadef3b6988..3be557109a76 100644 --- a/tests/codegen-llvm/enum/enum-early-otherwise-branch.rs +++ b/tests/codegen-llvm/enum/enum-early-otherwise-branch.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] pub enum Enum { A(u32), diff --git a/tests/codegen-llvm/enum/enum-match.rs b/tests/codegen-llvm/enum/enum-match.rs index 20e2006e3eb7..174d40a427f4 100644 --- a/tests/codegen-llvm/enum/enum-match.rs +++ b/tests/codegen-llvm/enum/enum-match.rs @@ -1,7 +1,9 @@ //@ compile-flags: -Copt-level=1 //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] +#![no_std] #![feature(core_intrinsics)] // Check each of the 3 cases for `codegen_get_discr`. @@ -176,7 +178,7 @@ pub fn match4_is_c(e: MiddleNiche) -> bool { // Before #139098, this couldn't optimize out the `select` because it looked // like it was possible for a `2` to be produced on both sides. - std::intrinsics::discriminant_value(&e) == 2 + core::intrinsics::discriminant_value(&e) == 2 } // You have to do something pretty obnoxious to get a variant index that doesn't @@ -737,7 +739,7 @@ pub enum Tricky { V200, } -const _: () = assert!(std::intrinsics::discriminant_value(&Tricky::V100) == 100); +const _: () = assert!(core::intrinsics::discriminant_value(&Tricky::V100) == 100); // CHECK-LABEL: define noundef{{( range\(i8 [0-9]+, [0-9]+\))?}} i8 @discriminant6(i8 noundef{{( zeroext)?}} %e) // CHECK-NEXT: start: @@ -748,7 +750,7 @@ const _: () = assert!(std::intrinsics::discriminant_value(&Tricky::V100) == 100) // CHECK-NEXT: ret i8 %[[DISCR]] #[no_mangle] pub fn discriminant6(e: Tricky) -> u8 { - std::intrinsics::discriminant_value(&e) as _ + core::intrinsics::discriminant_value(&e) as _ } // Case from , diff --git a/tests/codegen-llvm/enum/enum-transparent-extract.rs b/tests/codegen-llvm/enum/enum-transparent-extract.rs index 1435e6ec8022..1933886a8f98 100644 --- a/tests/codegen-llvm/enum/enum-transparent-extract.rs +++ b/tests/codegen-llvm/enum/enum-transparent-extract.rs @@ -1,9 +1,11 @@ //@ compile-flags: -Copt-level=0 //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] +#![no_std] -use std::ops::ControlFlow; +use core::ops::ControlFlow; pub enum Never {} diff --git a/tests/codegen-llvm/enum/enum-two-variants-match.rs b/tests/codegen-llvm/enum/enum-two-variants-match.rs index 12d9edc4d623..bb31f4ddc9bf 100644 --- a/tests/codegen-llvm/enum/enum-two-variants-match.rs +++ b/tests/codegen-llvm/enum/enum-two-variants-match.rs @@ -1,7 +1,9 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-64bit (because these discriminants are isize) +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] +#![no_std] // This directly tests what we emit for these matches, rather than what happens // after optimization, so it doesn't need to worry about extra flags on the @@ -76,7 +78,7 @@ pub fn option_bool_match(x: Option) -> char { } } -use std::cmp::Ordering::{self, *}; +use core::cmp::Ordering::{self, *}; // CHECK-LABEL: @option_ordering_match( #[no_mangle] pub fn option_ordering_match(x: Option) -> char { @@ -106,7 +108,7 @@ pub fn option_ordering_match(x: Option) -> char { // CHECK-LABEL: @option_nonzero_match( #[no_mangle] -pub fn option_nonzero_match(x: Option>) -> u16 { +pub fn option_nonzero_match(x: Option>) -> u16 { // CHECK: %[[OUT:.+]] = alloca [2 x i8] // CHECK: %[[IS_NONE:.+]] = icmp eq i16 %x, 0 diff --git a/tests/codegen-llvm/enum/unreachable_enum_default_branch.rs b/tests/codegen-llvm/enum/unreachable_enum_default_branch.rs index 55b165fc111d..d9f12cb57b17 100644 --- a/tests/codegen-llvm/enum/unreachable_enum_default_branch.rs +++ b/tests/codegen-llvm/enum/unreachable_enum_default_branch.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Int(u32); @@ -13,7 +14,7 @@ const C: Int = Int(153); // This code will basically turn into `matches!(x.partial_cmp(&A), Some(Greater | Equal))`. // The otherwise branch must be `Less`. // CHECK-LABEL: @implicit_match( -// CHECK-SAME: [[TMP0:%.*]]) +// CHECK-SAME: [[TMP0:%[a-z0-9]*]]) // CHECK-NEXT: start: // CHECK-NEXT: [[TMP1:%.*]] = add i32 [[TMP0]], -201 // CHECK-NEXT: icmp ult i32 [[TMP1]], 70 diff --git a/tests/codegen-llvm/gdb_debug_script_load.rs b/tests/codegen-llvm/gdb_debug_script_load.rs index 3e92eba10b12..3100d4194959 100644 --- a/tests/codegen-llvm/gdb_debug_script_load.rs +++ b/tests/codegen-llvm/gdb_debug_script_load.rs @@ -3,6 +3,7 @@ //@ ignore-apple //@ ignore-wasm //@ ignore-emscripten +//@ ignore-riscv32cheriot-unknown-cheriotrtos //@ compile-flags: -g -C no-prepopulate-passes -Cpanic=abort diff --git a/tests/codegen-llvm/simd/aggregate-simd.rs b/tests/codegen-llvm/simd/aggregate-simd.rs index 57a301d634c8..d157f0d3132b 100644 --- a/tests/codegen-llvm/simd/aggregate-simd.rs +++ b/tests/codegen-llvm/simd/aggregate-simd.rs @@ -1,5 +1,6 @@ //@ compile-flags: -C opt-level=3 -C no-prepopulate-passes //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![feature(core_intrinsics, repr_simd)] #![no_std] diff --git a/tests/codegen-llvm/slice-as_chunks.rs b/tests/codegen-llvm/slice-as_chunks.rs index 0f6ae21fa214..ecd755e8b6ab 100644 --- a/tests/codegen-llvm/slice-as_chunks.rs +++ b/tests/codegen-llvm/slice-as_chunks.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] diff --git a/tests/codegen-llvm/slice-indexing.rs b/tests/codegen-llvm/slice-indexing.rs index d957ccfb5ef7..432d8169d2b7 100644 --- a/tests/codegen-llvm/slice-indexing.rs +++ b/tests/codegen-llvm/slice-indexing.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] diff --git a/tests/codegen-llvm/slice-init.rs b/tests/codegen-llvm/slice-init.rs index 12e9df24565e..fb23eaacd044 100644 --- a/tests/codegen-llvm/slice-init.rs +++ b/tests/codegen-llvm/slice-init.rs @@ -1,12 +1,13 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @zero_sized_elem #[no_mangle] pub fn zero_sized_elem() { // CHECK-NOT: br label %repeat_loop_header{{.*}} - // CHECK-NOT: call void @llvm.memset.p0 + // CHECK-NOT: call void @llvm.memset. let x = [(); 4]; opaque(&x); } @@ -15,7 +16,7 @@ pub fn zero_sized_elem() { #[no_mangle] pub fn zero_len_array() { // CHECK-NOT: br label %repeat_loop_header{{.*}} - // CHECK-NOT: call void @llvm.memset.p0 + // CHECK-NOT: call void @llvm.memset. let x = [4; 0]; opaque(&x); } @@ -58,7 +59,7 @@ pub fn zeroed_integer_array() { #[no_mangle] pub fn nonzero_integer_array() { // CHECK: br label %repeat_loop_header{{.*}} - // CHECK-NOT: call void @llvm.memset.p0 + // CHECK-NOT: call void @llvm.memset. let x = [0x1a_2b_3c_4d_u32; 4]; opaque(&x); } @@ -72,7 +73,7 @@ pub fn u16_init_one_bytes() -> [u16; N] { // CHECK-NOT: br {{.*}} // CHECK-NOT: switch // CHECK-NOT: icmp - // CHECK: call void @llvm.memset.p0 + // CHECK: call void @llvm.memset. [const { u16::from_be_bytes([1, 1]) }; N] } @@ -85,11 +86,11 @@ pub fn option_none_init() -> [Option; N] { // CHECK: br label %repeat_loop_header{{.*}} // CHECK-NOT: switch // CHECK: icmp - // CHECK-NOT: call void @llvm.memset.p0 + // CHECK-NOT: call void @llvm.memset. [None; N] } -use std::mem::MaybeUninit; +use core::mem::MaybeUninit; // FIXME: This could be optimized into a memset. // Regression test for . @@ -99,7 +100,7 @@ pub fn half_uninit() -> [(u128, MaybeUninit); N] { // CHECK: br label %repeat_loop_header{{.*}} // CHECK-NOT: switch // CHECK: icmp - // CHECK-NOT: call void @llvm.memset.p0 + // CHECK-NOT: call void @llvm.memset. [const { (0, MaybeUninit::uninit()) }; N] } diff --git a/tests/codegen-llvm/slice-iter-fold.rs b/tests/codegen-llvm/slice-iter-fold.rs index c63b5f8f7acd..b316c9d8e4ba 100644 --- a/tests/codegen-llvm/slice-iter-fold.rs +++ b/tests/codegen-llvm/slice-iter-fold.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @slice_fold_to_last #[no_mangle] diff --git a/tests/codegen-llvm/slice-iter-len-eq-zero.rs b/tests/codegen-llvm/slice-iter-len-eq-zero.rs index 6998d98e498c..dd8be761f34e 100644 --- a/tests/codegen-llvm/slice-iter-len-eq-zero.rs +++ b/tests/codegen-llvm/slice-iter-len-eq-zero.rs @@ -1,4 +1,6 @@ +// ignore-tidy-linelength //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos CHERIoT will lower pointer equality to ptrtoint equality //@ needs-deterministic-layouts (opposite scalar pair orders breaks it) #![crate_type = "lib"] diff --git a/tests/codegen-llvm/slice-iter-nonnull.rs b/tests/codegen-llvm/slice-iter-nonnull.rs index 280594456c93..5a7deddcf8c6 100644 --- a/tests/codegen-llvm/slice-iter-nonnull.rs +++ b/tests/codegen-llvm/slice-iter-nonnull.rs @@ -1,7 +1,9 @@ //@ compile-flags: -Copt-level=3 //@ needs-deterministic-layouts +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/75 #![crate_type = "lib"] #![feature(exact_size_is_empty)] +#![no_std] // The slice iterator used to `assume` that the `start` pointer was non-null. // That ought to be unneeded, though, since the type is `NonNull`, so this test @@ -13,24 +15,24 @@ // CHECK-LABEL: @slice_iter_next( #[no_mangle] -pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { - // CHECK: %[[START:.+]] = load ptr, ptr %it, +pub fn slice_iter_next<'a>(it: &mut core::slice::Iter<'a, u32>) -> Option<&'a u32> { + // CHECK: %[[START:.+]] = load ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] %it, // CHECK-SAME: !nonnull // CHECK-SAME: !noundef - // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} - // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr[[ADDRSPACE]] %it, {{i32 4|i64 8}} + // CHECK: %[[END:.+]] = load ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] %[[ENDP]] // CHECK-SAME: !nonnull // CHECK-SAME: !noundef - // CHECK: icmp eq ptr %[[START]], %[[END]] + // CHECK: icmp eq ptr[[ADDRSPACE]] %[[START]], %[[END]] - // CHECK: store ptr{{.+}}, ptr %it, + // CHECK: store ptr[[ADDRSPACE]]{{.+}}, ptr[[ADDRSPACE]] %it, it.next() } // CHECK-LABEL: @slice_iter_next_back( #[no_mangle] -pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { +pub fn slice_iter_next_back<'a>(it: &mut core::slice::Iter<'a, u32>) -> Option<&'a u32> { // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] // CHECK-SAME: !nonnull @@ -53,7 +55,7 @@ pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&' // CHECK-LABEL: @slice_iter_new // CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef range({{.+}}) %slice.1) #[no_mangle] -pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> { +pub fn slice_iter_new(slice: &[u32]) -> core::slice::Iter<'_, u32> { // CHECK-NOT: slice // CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} i32{{.+}} %slice.0{{.+}} %slice.1 // CHECK-NOT: slice @@ -68,7 +70,7 @@ pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> { // CHECK-LABEL: @slice_iter_mut_new // CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef range({{.+}}) %slice.1) #[no_mangle] -pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> { +pub fn slice_iter_mut_new(slice: &mut [u32]) -> core::slice::IterMut<'_, u32> { // CHECK-NOT: slice // CHECK: %[[END:.+]] = getelementptr inbounds{{( nuw)?}} i32{{.+}} %slice.0{{.+}} %slice.1 // CHECK-NOT: slice @@ -82,7 +84,7 @@ pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> { // CHECK-LABEL: @slice_iter_is_empty #[no_mangle] -pub fn slice_iter_is_empty(it: &std::slice::Iter<'_, u32>) -> bool { +pub fn slice_iter_is_empty(it: &core::slice::Iter<'_, u32>) -> bool { // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] // CHECK-SAME: !nonnull @@ -98,7 +100,7 @@ pub fn slice_iter_is_empty(it: &std::slice::Iter<'_, u32>) -> bool { // CHECK-LABEL: @slice_iter_len #[no_mangle] -pub fn slice_iter_len(it: &std::slice::Iter<'_, u32>) -> usize { +pub fn slice_iter_len(it: &core::slice::Iter<'_, u32>) -> usize { // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] // CHECK-SAME: !nonnull diff --git a/tests/codegen-llvm/slice-last-elements-optimization.rs b/tests/codegen-llvm/slice-last-elements-optimization.rs index 77fc1d21cd90..c1e9e9473afd 100644 --- a/tests/codegen-llvm/slice-last-elements-optimization.rs +++ b/tests/codegen-llvm/slice-last-elements-optimization.rs @@ -1,5 +1,7 @@ //@ compile-flags: -Copt-level=3 + #![crate_type = "lib"] +#![no_std] // This test verifies that LLVM 20 properly optimizes the bounds check // when accessing the last few elements of a slice with proper conditions. diff --git a/tests/codegen-llvm/slice-len-math.rs b/tests/codegen-llvm/slice-len-math.rs index 4b7a6adb22c6..d4d558c962e1 100644 --- a/tests/codegen-llvm/slice-len-math.rs +++ b/tests/codegen-llvm/slice-len-math.rs @@ -1,5 +1,7 @@ //@ compile-flags: -C opt-level=3 + #![crate_type = "lib"] +#![no_std] #[no_mangle] // CHECK-LABEL: @len_plus_ten_a diff --git a/tests/codegen-llvm/slice-pointer-nonnull-unwrap.rs b/tests/codegen-llvm/slice-pointer-nonnull-unwrap.rs index 35e4bf2c6615..94a6ae1d804c 100644 --- a/tests/codegen-llvm/slice-pointer-nonnull-unwrap.rs +++ b/tests/codegen-llvm/slice-pointer-nonnull-unwrap.rs @@ -1,7 +1,10 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/76 + #![crate_type = "lib"] +#![no_std] -use std::ptr::NonNull; +use core::ptr::NonNull; // CHECK-LABEL: @slice_ptr_len_1 // CHECK-NEXT: {{.*}}: diff --git a/tests/codegen-llvm/slice-position-bounds-check.rs b/tests/codegen-llvm/slice-position-bounds-check.rs index 0d1d1d869ae2..3ea5568d67e4 100644 --- a/tests/codegen-llvm/slice-position-bounds-check.rs +++ b/tests/codegen-llvm/slice-position-bounds-check.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 -C panic=abort #![crate_type = "lib"] +#![no_std] fn search(arr: &mut [T], a: &T) -> Result { match arr.iter().position(|x| x == a) { diff --git a/tests/codegen-llvm/slice-ref-equality.rs b/tests/codegen-llvm/slice-ref-equality.rs index a5994c879485..8cd429157254 100644 --- a/tests/codegen-llvm/slice-ref-equality.rs +++ b/tests/codegen-llvm/slice-ref-equality.rs @@ -1,7 +1,8 @@ //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] +#![no_std] -use std::num::NonZero; +use core::num::NonZero; // #71602 reported a simple array comparison just generating a loop. // This was originally fixed by ensuring it generates a single bcmp, @@ -23,7 +24,7 @@ pub fn is_zero_slice_long(data: &[u8; 456]) -> bool { // CHECK-LABEL: @is_zero_slice_short #[no_mangle] pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr[[ADDRSPACE]] %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] &data[..] == [0; 4] @@ -32,7 +33,7 @@ pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { // CHECK-LABEL: @is_zero_array #[no_mangle] pub fn is_zero_array(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr[[ADDRSPACE]] %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] *data == [0; 4] diff --git a/tests/codegen-llvm/slice-split-at.rs b/tests/codegen-llvm/slice-split-at.rs index 07018cf9c917..08d25e96ea65 100644 --- a/tests/codegen-llvm/slice-split-at.rs +++ b/tests/codegen-llvm/slice-split-at.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // Check that no panic is generated in `split_at` when calculating the index for // the tail chunk using `checked_sub`. diff --git a/tests/codegen-llvm/slice-windows-no-bounds-check.rs b/tests/codegen-llvm/slice-windows-no-bounds-check.rs index 87e89b14f06c..93d8dd88c6a4 100644 --- a/tests/codegen-llvm/slice-windows-no-bounds-check.rs +++ b/tests/codegen-llvm/slice-windows-no-bounds-check.rs @@ -1,8 +1,9 @@ -#![crate_type = "lib"] - //@ compile-flags: -Copt-level=3 -use std::slice::Windows; +#![crate_type = "lib"] +#![no_std] + +use core::slice::Windows; // CHECK-LABEL: @naive_string_search #[no_mangle] diff --git a/tests/codegen-llvm/slice_as_from_ptr_range.rs b/tests/codegen-llvm/slice_as_from_ptr_range.rs index 2073f05c07f0..4853114055cf 100644 --- a/tests/codegen-llvm/slice_as_from_ptr_range.rs +++ b/tests/codegen-llvm/slice_as_from_ptr_range.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 //@ only-64bit (because we're using [ui]size) +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize #![crate_type = "lib"] #![feature(slice_from_ptr_range)] diff --git a/tests/codegen-llvm/to_vec.rs b/tests/codegen-llvm/to_vec.rs index 4f6e77188d81..bdc32f4eebd3 100644 --- a/tests/codegen-llvm/to_vec.rs +++ b/tests/codegen-llvm/to_vec.rs @@ -1,6 +1,10 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; // CHECK-LABEL: @copy_to_vec #[no_mangle] diff --git a/tests/codegen-llvm/ub-checks.rs b/tests/codegen-llvm/ub-checks.rs index c40bc9acc52a..e40cc2df4600 100644 --- a/tests/codegen-llvm/ub-checks.rs +++ b/tests/codegen-llvm/ub-checks.rs @@ -11,8 +11,9 @@ //@ compile-flags: -Copt-level=3 -Cdebug-assertions=yes #![crate_type = "lib"] +#![no_std] -use std::ops::Range; +use core::ops::Range; // CHECK-LABEL: @slice_get_unchecked( #[no_mangle] diff --git a/tests/codegen-llvm/unchecked-float-casts.rs b/tests/codegen-llvm/unchecked-float-casts.rs index d1869abc87bb..f3a239fcb457 100644 --- a/tests/codegen-llvm/unchecked-float-casts.rs +++ b/tests/codegen-llvm/unchecked-float-casts.rs @@ -5,6 +5,7 @@ //@ ignore-wasm32 the wasm target is tested in `wasm_casts_*` #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @f32_to_u32 #[no_mangle] diff --git a/tests/codegen-llvm/unchecked_shifts.rs b/tests/codegen-llvm/unchecked_shifts.rs index 2e17a827f62f..f0c0c8b78f3c 100644 --- a/tests/codegen-llvm/unchecked_shifts.rs +++ b/tests/codegen-llvm/unchecked_shifts.rs @@ -4,6 +4,7 @@ // optimizations so it doesn't need to worry about them adding more flags. #![crate_type = "lib"] +#![no_std] #![feature(core_intrinsics)] // CHECK-LABEL: @unchecked_shl_unsigned_same @@ -68,7 +69,7 @@ pub unsafe fn unchecked_shr_u128_i8(a: u128, b: i8) -> u128 { // CHECK-NOT: assume // CHECK: %[[EXT:.+]] = zext i8 %b to i128 // CHECK: lshr i128 %a, %[[EXT]] - std::intrinsics::unchecked_shr(a, b) + core::intrinsics::unchecked_shr(a, b) } // CHECK-LABEL: @unchecked_shl_i128_u8 @@ -77,7 +78,7 @@ pub unsafe fn unchecked_shl_i128_u8(a: i128, b: u8) -> i128 { // CHECK-NOT: assume // CHECK: %[[EXT:.+]] = zext i8 %b to i128 // CHECK: shl i128 %a, %[[EXT]] - std::intrinsics::unchecked_shl(a, b) + core::intrinsics::unchecked_shl(a, b) } // CHECK-LABEL: @unchecked_shl_u8_i128 @@ -86,7 +87,7 @@ pub unsafe fn unchecked_shl_u8_i128(a: u8, b: i128) -> u8 { // CHECK-NOT: assume // CHECK: %[[TRUNC:.+]] = trunc nuw i128 %b to i8 // CHECK: shl i8 %a, %[[TRUNC]] - std::intrinsics::unchecked_shl(a, b) + core::intrinsics::unchecked_shl(a, b) } // CHECK-LABEL: @unchecked_shr_i8_u128 @@ -95,5 +96,5 @@ pub unsafe fn unchecked_shr_i8_u128(a: i8, b: u128) -> i8 { // CHECK-NOT: assume // CHECK: %[[TRUNC:.+]] = trunc nuw i128 %b to i8 // CHECK: ashr i8 %a, %[[TRUNC]] - std::intrinsics::unchecked_shr(a, b) + core::intrinsics::unchecked_shr(a, b) } diff --git a/tests/codegen-llvm/uninhabited-transparent-return-abi.rs b/tests/codegen-llvm/uninhabited-transparent-return-abi.rs index 507cd7ae2a67..d7365aaf4d34 100644 --- a/tests/codegen-llvm/uninhabited-transparent-return-abi.rs +++ b/tests/codegen-llvm/uninhabited-transparent-return-abi.rs @@ -3,6 +3,7 @@ // See https://github.com/rust-lang/rust/issues/135802 #![crate_type = "lib"] +#![no_std] enum Void {} @@ -23,7 +24,7 @@ extern "Rust" { #[no_mangle] pub fn test_uninhabited_ret_by_ref() { // CHECK: %_1 = alloca [24 x i8], align {{8|4}} - // CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 24, )?}}ptr nonnull %_1) + // CHECK-NEXT: call void @llvm.lifetime.start.p{{[0-9]+}}({{(i64 24, )?}}ptr[[ADDRSPACE]] nonnull %_1) // CHECK-NEXT: call void @opaque({{.*}} sret([24 x i8]) {{.*}} %_1) #2 // CHECK-NEXT: unreachable unsafe { @@ -35,7 +36,7 @@ pub fn test_uninhabited_ret_by_ref() { #[no_mangle] pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) { // CHECK: %_2 = alloca [24 x i8], align {{8|4}} - // CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 24, )?}}ptr nonnull %_2) + // CHECK-NEXT: call void @llvm.lifetime.start.p{{[0-9]+}}({{(i64 24, )?}}ptr[[ADDRSPACE]] nonnull %_2) // CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef{{( signext)?}} %rsi) #2 // CHECK-NEXT: unreachable unsafe { diff --git a/tests/codegen-llvm/uninit-consts.rs b/tests/codegen-llvm/uninit-consts.rs index 6724c0631713..860dab73f321 100644 --- a/tests/codegen-llvm/uninit-consts.rs +++ b/tests/codegen-llvm/uninit-consts.rs @@ -3,19 +3,20 @@ // Check that we use undef (and not zero) for uninitialized bytes in constants. #![crate_type = "lib"] +#![no_std] -use std::mem::MaybeUninit; +use core::mem::MaybeUninit; pub struct PartiallyUninit { x: u32, y: MaybeUninit<[u8; 10]>, } -// CHECK: [[PARTIALLY_UNINIT:@.*]] = private unnamed_addr constant <{ [4 x i8], [12 x i8] }> <{ [4 x i8] c"{{\\EF\\BE\\AD\\DE|\\DE\\AD\\BE\\EF}}", [12 x i8] undef }>, align 4 +// CHECK: [[PARTIALLY_UNINIT:@.*]] = private unnamed_addr[[ADDRSPACE]] constant <{ [4 x i8], [12 x i8] }> <{ [4 x i8] c"{{\\EF\\BE\\AD\\DE|\\DE\\AD\\BE\\EF}}", [12 x i8] undef }>, align 4 // This shouldn't contain undef, since it contains more chunks // than the default value of uninit_const_chunk_threshold. -// CHECK: [[UNINIT_PADDING_HUGE:@.*]] = private unnamed_addr constant [32768 x i8] c"{{.+}}", align 4 +// CHECK: [[UNINIT_PADDING_HUGE:@.*]] = private unnamed_addr[[ADDRSPACE]] constant [32768 x i8] c"{{.+}}", align 4 // CHECK-LABEL: @fully_uninit #[no_mangle] @@ -31,7 +32,7 @@ pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> { #[no_mangle] pub const fn partially_uninit() -> PartiallyUninit { const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeef, y: MaybeUninit::uninit() }; - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[PARTIALLY_UNINIT]]{{.*}}, i{{(32|64)}} 16, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 4 %_0, ptr[[ADDRSPACE]] align 4 {{.*}}[[PARTIALLY_UNINIT]]{{.*}}, i{{(32|64)}} 16, i1 false) X } @@ -39,7 +40,7 @@ pub const fn partially_uninit() -> PartiallyUninit { #[no_mangle] pub const fn uninit_padding_huge() -> [(u32, u8); 4096] { const X: [(u32, u8); 4096] = [(123, 45); 4096]; - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[UNINIT_PADDING_HUGE]]{{.*}}, i{{(32|64)}} 32768, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}(ptr[[ADDRSPACE]] align 4 %_0, ptr[[ADDRSPACE]] align 4 {{.*}}[[UNINIT_PADDING_HUGE]]{{.*}}, i{{(32|64)}} 32768, i1 false) X } diff --git a/tests/codegen-llvm/uninit-repeat-in-aggregate.rs b/tests/codegen-llvm/uninit-repeat-in-aggregate.rs index 0fa2eb7d56cd..9eb297b77bfe 100644 --- a/tests/codegen-llvm/uninit-repeat-in-aggregate.rs +++ b/tests/codegen-llvm/uninit-repeat-in-aggregate.rs @@ -1,8 +1,12 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] -use std::mem::MaybeUninit; +use core::mem::MaybeUninit; + +extern crate alloc; +use alloc::string::String; // We need to make sure len is at offset 0, otherwise codegen needs an extra instruction #[repr(C)] diff --git a/tests/codegen-llvm/union-abi.rs b/tests/codegen-llvm/union-abi.rs index 28acc4de2f32..1878c33940fa 100644 --- a/tests/codegen-llvm/union-abi.rs +++ b/tests/codegen-llvm/union-abi.rs @@ -16,6 +16,7 @@ // discussed in #54668 #![crate_type = "lib"] +#![no_std] #![feature(repr_simd)] #[derive(Copy, Clone)] @@ -31,7 +32,7 @@ pub union UnionI64x4 { b: i64x4, } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr[[ADDRSPACE]] {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4(_: UnionI64x4) { loop {} @@ -46,7 +47,7 @@ pub union UnionI64x4_ { f: UnionI64x4, } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr[[ADDRSPACE]] {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} @@ -57,7 +58,7 @@ pub union UnionI64x4I64 { b: i64, } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr[[ADDRSPACE]] {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} @@ -68,7 +69,7 @@ pub union UnionI64x4Tuple { b: (i64, i64, i64, i64), } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr[[ADDRSPACE]] {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} @@ -128,7 +129,7 @@ pub fn test_UnionU128(_: UnionU128) -> UnionU128 { pub union CUnionU128 { a: u128, } -// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr[[ADDRSPACE]] {{.*}} %_1) #[no_mangle] pub fn test_CUnionU128(_: CUnionU128) { loop {} diff --git a/tests/codegen-llvm/union-aggregate.rs b/tests/codegen-llvm/union-aggregate.rs index 7faa66804fea..9f100a2e9cd5 100644 --- a/tests/codegen-llvm/union-aggregate.rs +++ b/tests/codegen-llvm/union-aggregate.rs @@ -1,7 +1,9 @@ //@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 as usize #![crate_type = "lib"] +#![no_std] #![feature(transparent_unions)] #![feature(repr_simd)] @@ -11,9 +13,9 @@ union MU { value: T, } -use std::cmp::Ordering; -use std::num::NonZero; -use std::ptr::NonNull; +use core::cmp::Ordering; +use core::num::NonZero; +use core::ptr::NonNull; #[no_mangle] fn make_mu_bool(x: bool) -> MU { diff --git a/tests/codegen-llvm/used_with_arg.rs b/tests/codegen-llvm/used_with_arg.rs index 4515cb2aed0c..a2dadf730d4b 100644 --- a/tests/codegen-llvm/used_with_arg.rs +++ b/tests/codegen-llvm/used_with_arg.rs @@ -1,10 +1,11 @@ #![crate_type = "lib"] #![feature(used_with_arg)] +#![no_std] -// CHECK: @llvm.used = appending global {{.*}}USED_LINKER +// CHECK: @llvm.used = appending[[ADDRSPACE]] global {{.*}}USED_LINKER #[used(linker)] static mut USED_LINKER: [usize; 1] = [0]; -// CHECK-NEXT: @llvm.compiler.used = appending global {{.*}}USED_COMPILER +// CHECK-NEXT: @llvm.compiler.used = appending[[ADDRSPACE]] global {{.*}}USED_COMPILER #[used(compiler)] static mut USED_COMPILER: [usize; 1] = [0]; diff --git a/tests/codegen-llvm/var-names.rs b/tests/codegen-llvm/var-names.rs index 40720e197614..deae0a6021a3 100644 --- a/tests/codegen-llvm/var-names.rs +++ b/tests/codegen-llvm/var-names.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: define{{.*}}i32 @test(i32{{.*}} %a, i32{{.*}} %b) #[no_mangle] diff --git a/tests/codegen-llvm/vec-as-ptr.rs b/tests/codegen-llvm/vec-as-ptr.rs index 5c997802640d..49ea5522e71a 100644 --- a/tests/codegen-llvm/vec-as-ptr.rs +++ b/tests/codegen-llvm/vec-as-ptr.rs @@ -1,10 +1,14 @@ //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull ptr @vec_as_ptr +// CHECK: nonnull ptr[[ADDRSPACE]] @vec_as_ptr #[no_mangle] pub fn vec_as_ptr(v: &Vec) -> *const u8 { v.as_ptr() @@ -12,7 +16,7 @@ pub fn vec_as_ptr(v: &Vec) -> *const u8 { // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull ptr @vec_as_mut_ptr +// CHECK: nonnull ptr[[ADDRSPACE]] @vec_as_mut_ptr #[no_mangle] pub fn vec_as_mut_ptr(v: &mut Vec) -> *mut u8 { v.as_mut_ptr() diff --git a/tests/codegen-llvm/vec-iter-collect-len.rs b/tests/codegen-llvm/vec-iter-collect-len.rs index 807548ef883f..cb0d8b8f06a2 100644 --- a/tests/codegen-llvm/vec-iter-collect-len.rs +++ b/tests/codegen-llvm/vec-iter-collect-len.rs @@ -1,5 +1,11 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/77 + #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; #[no_mangle] pub fn get_len() -> usize { diff --git a/tests/codegen-llvm/vec-iter.rs b/tests/codegen-llvm/vec-iter.rs index 4ed00d2d34f0..f05a2f150f3b 100644 --- a/tests/codegen-llvm/vec-iter.rs +++ b/tests/codegen-llvm/vec-iter.rs @@ -1,8 +1,10 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] #![feature(exact_size_is_empty)] -use std::vec; +extern crate alloc; +use alloc::vec; // CHECK-LABEL: @vec_iter_len_nonnull #[no_mangle] diff --git a/tests/codegen-llvm/vec-len-invariant.rs b/tests/codegen-llvm/vec-len-invariant.rs index 033181c2bfb7..112ec95278d6 100644 --- a/tests/codegen-llvm/vec-len-invariant.rs +++ b/tests/codegen-llvm/vec-len-invariant.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Copt-level=3 //@ only-64bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize // // This test confirms that we do not reload the length of a Vec after growing it in push. diff --git a/tests/codegen-llvm/vec-optimizes-away.rs b/tests/codegen-llvm/vec-optimizes-away.rs index 93b55454b108..dfffde29390f 100644 --- a/tests/codegen-llvm/vec-optimizes-away.rs +++ b/tests/codegen-llvm/vec-optimizes-away.rs @@ -1,5 +1,11 @@ //@ compile-flags: -Copt-level=3 +//@ ignore-riscv32cheriot-unknown-cheriotrtos FIXME: See CHERIoT-Platform/cheri-rust/issues/78 + #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec; #[no_mangle] pub fn sum_me() -> i32 { diff --git a/tests/codegen-llvm/vec-reserve-extend.rs b/tests/codegen-llvm/vec-reserve-extend.rs index 4d3f23ccecfc..73c385d55804 100644 --- a/tests/codegen-llvm/vec-reserve-extend.rs +++ b/tests/codegen-llvm/vec-reserve-extend.rs @@ -1,6 +1,10 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; // CHECK-LABEL: @should_reserve_once #[no_mangle] diff --git a/tests/codegen-llvm/vec_pop_push_noop.rs b/tests/codegen-llvm/vec_pop_push_noop.rs index 977c220b3bae..ea5192e1871b 100644 --- a/tests/codegen-llvm/vec_pop_push_noop.rs +++ b/tests/codegen-llvm/vec_pop_push_noop.rs @@ -4,6 +4,10 @@ //@ [new] min-llvm-version: 22 #![crate_type = "lib"] +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; #[no_mangle] // CHECK-LABEL: @noop( diff --git a/tests/codegen-llvm/vecdeque-nonempty-get-no-panic.rs b/tests/codegen-llvm/vecdeque-nonempty-get-no-panic.rs index 1f886b096bbb..382273f6a469 100644 --- a/tests/codegen-llvm/vecdeque-nonempty-get-no-panic.rs +++ b/tests/codegen-llvm/vecdeque-nonempty-get-no-panic.rs @@ -3,8 +3,10 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] -use std::collections::VecDeque; +extern crate alloc; +use alloc::collections::VecDeque; // CHECK-LABEL: @front // CHECK: ret void diff --git a/tests/codegen-llvm/vecdeque_pop_push.rs b/tests/codegen-llvm/vecdeque_pop_push.rs index 6f9ad6674d6c..6410423332de 100644 --- a/tests/codegen-llvm/vecdeque_pop_push.rs +++ b/tests/codegen-llvm/vecdeque_pop_push.rs @@ -4,8 +4,10 @@ //@ [new] min-llvm-version: 22 #![crate_type = "lib"] +#![no_std] -use std::collections::VecDeque; +extern crate alloc; +use alloc::collections::VecDeque; #[no_mangle] // CHECK-LABEL: @noop_back( diff --git a/tests/codegen-llvm/virtual-call-attrs-issue-137646.rs b/tests/codegen-llvm/virtual-call-attrs-issue-137646.rs index 5e453947f27d..affbb969218c 100644 --- a/tests/codegen-llvm/virtual-call-attrs-issue-137646.rs +++ b/tests/codegen-llvm/virtual-call-attrs-issue-137646.rs @@ -4,6 +4,7 @@ //@ compile-flags: -C opt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] +#![no_std] #![feature(rustc_attrs)] pub trait Trait { diff --git a/tests/codegen-llvm/virtual-function-elimination.rs b/tests/codegen-llvm/virtual-function-elimination.rs index 26604478c11a..2f73c3c55fdc 100644 --- a/tests/codegen-llvm/virtual-function-elimination.rs +++ b/tests/codegen-llvm/virtual-function-elimination.rs @@ -1,13 +1,16 @@ //@ compile-flags: -Zvirtual-function-elimination -Clto -Copt-level=3 -Csymbol-mangling-version=v0 //@ ignore-32bit +//@ ignore-riscv32cheriot-unknown-cheriotrtos Uses i64 for usize // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] // CHECK: @vtable.1 = {{.*}}, !type ![[TYPE1:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] // CHECK: @vtable.2 = {{.*}}, !type ![[TYPE2:[0-9]+]], !vcall_visibility ![[VCALL_VIS2:[0-9]+]] #![crate_type = "lib"] +#![no_std] -use std::rc::Rc; +extern crate alloc; +use alloc::rc::Rc; trait T { // CHECK-LABEL: ; ::used diff --git a/tests/codegen-llvm/vtable-loads.rs b/tests/codegen-llvm/vtable-loads.rs index aa103ec6f7cb..f1b7a8126fae 100644 --- a/tests/codegen-llvm/vtable-loads.rs +++ b/tests/codegen-llvm/vtable-loads.rs @@ -1,13 +1,14 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @loop_skips_vtable_load #[no_mangle] pub fn loop_skips_vtable_load(x: &dyn Fn()) { - // CHECK: load ptr, ptr %0{{.*}}, !invariant.load + // CHECK: load ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] %0{{.*}}, !invariant.load // CHECK-NEXT: tail call void %1 - // CHECK-NOT: load ptr + // CHECK-NOT: load ptr[[ADDRSPACE]] x(); for _ in 0..100 { // CHECK: tail call void %1 diff --git a/tests/codegen-llvm/vtable-upcast.rs b/tests/codegen-llvm/vtable-upcast.rs index 9e13e8dd68ac..89fba27e079c 100644 --- a/tests/codegen-llvm/vtable-upcast.rs +++ b/tests/codegen-llvm/vtable-upcast.rs @@ -2,6 +2,7 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] +#![no_std] pub trait Base { fn base(&self); @@ -56,17 +57,17 @@ pub fn upcast_diamond_to_a(x: &dyn Diamond) -> &dyn A { } // CHECK-LABEL: upcast_diamond_to_b -// CHECK-SAME: (ptr align {{[0-9]+}} [[DATA_PTR:%.+]], ptr align {{[0-9]+}} [[VTABLE_PTR:%.+]]) +// CHECK-SAME: (ptr[[ADDRSPACE]] align {{[0-9]+}} [[DATA_PTR:%.+]], ptr[[ADDRSPACE]] align {{[0-9]+}} [[VTABLE_PTR:%[a-zA-Z0-9.]+]]) #[no_mangle] pub fn upcast_diamond_to_b(x: &dyn Diamond) -> &dyn B { // Requires adjustment, since it's a non-first supertrait. // CHECK: start: - // CHECK-NEXT: [[UPCAST_SLOT_PTR:%.+]] = getelementptr inbounds i8, ptr [[VTABLE_PTR]] - // CHECK-NEXT: [[UPCAST_VTABLE_PTR:%.+]] = load ptr, ptr [[UPCAST_SLOT_PTR]] - // CHECK-NEXT: [[FAT_PTR_1:%.+]] = insertvalue { ptr, ptr } poison, ptr [[DATA_PTR]], 0 - // CHECK-NEXT: [[FAT_PTR_2:%.+]] = insertvalue { ptr, ptr } [[FAT_PTR_1]], ptr [[UPCAST_VTABLE_PTR]], 1 - // CHECK-NEXT: ret { ptr, ptr } [[FAT_PTR_2]] + // CHECK-NEXT: [[UPCAST_SLOT_PTR:%.+]] = getelementptr inbounds i8, ptr[[ADDRSPACE]] [[VTABLE_PTR]] + // CHECK-NEXT: [[UPCAST_VTABLE_PTR:%.+]] = load ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] [[UPCAST_SLOT_PTR]] + // CHECK-NEXT: [[FAT_PTR_1:%.+]] = insertvalue { ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] } poison, ptr[[ADDRSPACE]] [[DATA_PTR]], 0 + // CHECK-NEXT: [[FAT_PTR_2:%.+]] = insertvalue { ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] } [[FAT_PTR_1]], ptr[[ADDRSPACE]] [[UPCAST_VTABLE_PTR]], 1 + // CHECK-NEXT: ret { ptr[[ADDRSPACE]], ptr[[ADDRSPACE]] } [[FAT_PTR_2]] x as &dyn B } diff --git a/tests/codegen-llvm/zip.rs b/tests/codegen-llvm/zip.rs index 38ecf7c15c67..7e1040fb78d9 100644 --- a/tests/codegen-llvm/zip.rs +++ b/tests/codegen-llvm/zip.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Cno-prepopulate-passes -Copt-level=3 #![crate_type = "lib"] +#![no_std] // CHECK-LABEL: @zip_copy #[no_mangle] diff --git a/tests/codegen-llvm/zst-offset.rs b/tests/codegen-llvm/zst-offset.rs index 475394a88156..68b31cce4ff3 100644 --- a/tests/codegen-llvm/zst-offset.rs +++ b/tests/codegen-llvm/zst-offset.rs @@ -2,9 +2,10 @@ #![crate_type = "lib"] #![feature(repr_simd)] +#![no_std] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]]{{( signext)?}} %_1) #[no_mangle] pub fn helper(_: usize) {}