about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-30 07:06:57 +0000
committerbors <bors@rust-lang.org>2024-05-30 07:06:57 +0000
commit8a7338ab4d1bf61a62d5fa44e58825bfd9335210 (patch)
treeebc9bed11eeedb7301c32cb9e3db15b5c9a1c865 /tests/codegen
parentec5327d0b77a1248a2c9b8c7c76ae70a867b39fe (diff)
parentdaeb68a579d0a0e8e3de0d1cd39c60c2d0a30a87 (diff)
Auto merge of #3645 - rust-lang:rustup-2024-05-30, r=RalfJung
Automatic Rustup
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/fixed-x18.rs22
-rw-r--r--tests/codegen/gdb_debug_script_load.rs2
-rw-r--r--tests/codegen/instrument-coverage/testprog.rs4
-rw-r--r--tests/codegen/intrinsics/ptr_metadata.rs36
-rw-r--r--tests/codegen/issues/issue-44056-macos-tls-align.rs2
-rw-r--r--tests/codegen/mainsubprogram.rs5
-rw-r--r--tests/codegen/mainsubprogramstart.rs2
-rw-r--r--tests/codegen/pgo-counter-bias.rs2
-rw-r--r--tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs44
-rw-r--r--tests/codegen/vtable-loads.rs16
10 files changed, 105 insertions, 30 deletions
diff --git a/tests/codegen/fixed-x18.rs b/tests/codegen/fixed-x18.rs
new file mode 100644
index 00000000000..4997a39a726
--- /dev/null
+++ b/tests/codegen/fixed-x18.rs
@@ -0,0 +1,22 @@
+// Test that the `reserve-x18` target feature is (not) emitted when
+// the `-Zfixed-x18` flag is (not) set.
+
+//@ revisions: unset set
+//@ needs-llvm-components: aarch64
+//@ compile-flags: --target aarch64-unknown-none
+//@ [set] compile-flags: -Zfixed-x18
+
+#![crate_type = "lib"]
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[no_mangle]
+pub fn foo() {
+    // CHECK: @foo() unnamed_addr #0
+
+    // unset-NOT: attributes #0 = { {{.*}}"target-features"="{{[^"]*}}+reserve-x18{{.*}} }
+    // set: attributes #0 = { {{.*}}"target-features"="{{[^"]*}}+reserve-x18{{.*}} }
+}
diff --git a/tests/codegen/gdb_debug_script_load.rs b/tests/codegen/gdb_debug_script_load.rs
index f15defeaca8..30d518c0bcb 100644
--- a/tests/codegen/gdb_debug_script_load.rs
+++ b/tests/codegen/gdb_debug_script_load.rs
@@ -1,6 +1,6 @@
 //
 //@ ignore-windows
-//@ ignore-macos
+//@ ignore-apple
 //@ ignore-wasm
 //@ ignore-emscripten
 
diff --git a/tests/codegen/instrument-coverage/testprog.rs b/tests/codegen/instrument-coverage/testprog.rs
index b352cbdb755..acc4f35d905 100644
--- a/tests/codegen/instrument-coverage/testprog.rs
+++ b/tests/codegen/instrument-coverage/testprog.rs
@@ -11,7 +11,7 @@
 //@ [LINUX] filecheck-flags: -DINSTR_PROF_COVFUN=__llvm_covfun
 //@ [LINUX] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat'
 
-//@ [DARWIN] only-macos
+//@ [DARWIN] only-apple
 //@ [DARWIN] filecheck-flags: -DINSTR_PROF_DATA=__DATA,__llvm_prf_data,regular,live_support
 //@ [DARWIN] filecheck-flags: -DINSTR_PROF_NAME=__DATA,__llvm_prf_names
 //@ [DARWIN] filecheck-flags: -DINSTR_PROF_CNTS=__DATA,__llvm_prf_cnts
@@ -49,7 +49,7 @@ where
 
 pub fn wrap_with<F, T>(inner: T, should_wrap: bool, wrapper: F)
 where
-    F: FnOnce(&T)
+    F: FnOnce(&T),
 {
     if should_wrap {
         wrapper(&inner)
diff --git a/tests/codegen/intrinsics/ptr_metadata.rs b/tests/codegen/intrinsics/ptr_metadata.rs
new file mode 100644
index 00000000000..f4bf5a1f5f1
--- /dev/null
+++ b/tests/codegen/intrinsics/ptr_metadata.rs
@@ -0,0 +1,36 @@
+//@ compile-flags: -O -C no-prepopulate-passes -Z inline-mir
+//@ only-64bit (so I don't need to worry about usize)
+
+#![crate_type = "lib"]
+#![feature(core_intrinsics)]
+
+use std::intrinsics::ptr_metadata;
+
+// CHECK-LABEL: @thin_metadata(
+#[no_mangle]
+pub fn thin_metadata(p: *const ()) {
+    // CHECK: start
+    // CHECK-NEXT: ret void
+    ptr_metadata(p)
+}
+
+// CHECK-LABEL: @slice_metadata(
+#[no_mangle]
+pub fn slice_metadata(p: *const [u8]) -> usize {
+    // CHECK: start
+    // CHECK-NEXT: ret i64 %p.1
+    ptr_metadata(p)
+}
+
+// CHECK-LABEL: @dyn_byte_offset(
+#[no_mangle]
+pub unsafe fn dyn_byte_offset(
+    p: *const dyn std::fmt::Debug,
+    n: usize,
+) -> *const dyn std::fmt::Debug {
+    // CHECK: %[[Q:.+]] = getelementptr inbounds i8, ptr %p.0, i64 %n
+    // CHECK: %[[TEMP1:.+]] = insertvalue { ptr, ptr } poison, ptr %[[Q]], 0
+    // CHECK: %[[TEMP2:.+]] = insertvalue { ptr, ptr } %[[TEMP1]], ptr %p.1, 1
+    // CHECK: ret { ptr, ptr } %[[TEMP2]]
+    p.byte_add(n)
+}
diff --git a/tests/codegen/issues/issue-44056-macos-tls-align.rs b/tests/codegen/issues/issue-44056-macos-tls-align.rs
index c99f0b73038..972b8490d18 100644
--- a/tests/codegen/issues/issue-44056-macos-tls-align.rs
+++ b/tests/codegen/issues/issue-44056-macos-tls-align.rs
@@ -1,5 +1,5 @@
 //
-//@ only-macos
+//@ only-apple
 //@ compile-flags: -O
 
 #![crate_type = "rlib"]
diff --git a/tests/codegen/mainsubprogram.rs b/tests/codegen/mainsubprogram.rs
index c1933b2b390..12b24c90229 100644
--- a/tests/codegen/mainsubprogram.rs
+++ b/tests/codegen/mainsubprogram.rs
@@ -2,7 +2,7 @@
 // before 4.0, formerly backported to the Rust LLVM fork.
 
 //@ ignore-windows
-//@ ignore-macos
+//@ ignore-apple
 //@ ignore-wasi
 
 //@ compile-flags: -g -C no-prepopulate-passes
@@ -10,5 +10,4 @@
 // CHECK-LABEL: @main
 // CHECK: {{.*}}DISubprogram{{.*}}name: "main",{{.*}}DI{{(SP)?}}FlagMainSubprogram{{.*}}
 
-pub fn main() {
-}
+pub fn main() {}
diff --git a/tests/codegen/mainsubprogramstart.rs b/tests/codegen/mainsubprogramstart.rs
index 84d680b9bff..20741791db5 100644
--- a/tests/codegen/mainsubprogramstart.rs
+++ b/tests/codegen/mainsubprogramstart.rs
@@ -1,5 +1,5 @@
 //@ ignore-windows
-//@ ignore-macos
+//@ ignore-apple
 //@ ignore-wasi wasi codegens the main symbol differently
 
 //@ compile-flags: -g -C no-prepopulate-passes
diff --git a/tests/codegen/pgo-counter-bias.rs b/tests/codegen/pgo-counter-bias.rs
index 1263eaf206f..87d31073d5a 100644
--- a/tests/codegen/pgo-counter-bias.rs
+++ b/tests/codegen/pgo-counter-bias.rs
@@ -1,6 +1,6 @@
 // Test that __llvm_profile_counter_bias does not get internalized by lto.
 
-//@ ignore-macos -runtime-counter-relocation not honored on Mach-O
+//@ ignore-apple -runtime-counter-relocation not honored on Mach-O
 //@ compile-flags: -Cprofile-generate -Cllvm-args=-runtime-counter-relocation -Clto=fat
 //@ needs-profiler-support
 //@ no-prefer-dynamic
diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs
index 6c3d991af9f..4e5ad8ad4a9 100644
--- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs
+++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs
@@ -4,7 +4,7 @@
 //@ needs-sanitizer-cfi
 //@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
 
-#![crate_type="lib"]
+#![crate_type = "lib"]
 #![feature(type_alias_impl_trait)]
 
 extern crate core;
@@ -14,14 +14,15 @@ pub type Type2 = impl Send;
 pub type Type3 = impl Send;
 pub type Type4 = impl Send;
 
-pub fn foo() where
+pub fn foo()
+where
     Type1: 'static,
     Type2: 'static,
     Type3: 'static,
     Type4: 'static,
 {
     // Type in extern path
-    extern {
+    extern "C" {
         fn bar();
     }
     let _: Type1 = bar;
@@ -35,43 +36,44 @@ pub fn foo() where
     // Type in const path
     const {
         pub struct Foo;
-        fn bar() -> Type3 { Foo }
+        fn bar() -> Type3 {
+            Foo
+        }
     };
 
-
     // Type in impl path
     struct Foo;
     impl Foo {
-        fn bar(&self) { }
+        fn bar(&self) {}
     }
     let _: Type4 = <Foo>::bar;
 }
 
 // Force arguments to be passed by using a reference. Otherwise, they may end up PassMode::Ignore
 
-pub fn foo1(_: &Type1) { }
+pub fn foo1(_: &Type1) {}
 // CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo2(_: &Type1, _: &Type1) { }
+pub fn foo2(_: &Type1, _: &Type1) {}
 // CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo3(_: &Type1, _: &Type1, _: &Type1) { }
+pub fn foo3(_: &Type1, _: &Type1, _: &Type1) {}
 // CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo4(_: &Type2) { }
+pub fn foo4(_: &Type2) {}
 // CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo5(_: &Type2, _: &Type2) { }
+pub fn foo5(_: &Type2, _: &Type2) {}
 // CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo6(_: &Type2, _: &Type2, _: &Type2) { }
+pub fn foo6(_: &Type2, _: &Type2, _: &Type2) {}
 // CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo7(_: &Type3) { }
+pub fn foo7(_: &Type3) {}
 // CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo8(_: &Type3, _: &Type3) { }
+pub fn foo8(_: &Type3, _: &Type3) {}
 // CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo9(_: &Type3, _: &Type3, _: &Type3) { }
+pub fn foo9(_: &Type3, _: &Type3, _: &Type3) {}
 // CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo10(_: &Type4) { }
+pub fn foo10(_: &Type4) {}
 // CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo11(_: &Type4, _: &Type4) { }
+pub fn foo11(_: &Type4, _: &Type4) {}
 // CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
-pub fn foo12(_: &Type4, _: &Type4, _: &Type4) { }
+pub fn foo12(_: &Type4, _: &Type4, _: &Type4) {}
 // CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
 
 // CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo10{{[{}][{}]}}extern{{[}][}]}}3barEE"}
@@ -80,9 +82,9 @@ pub fn foo12(_: &Type4, _: &Type4, _: &Type4) { }
 // CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooEE"}
 // CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooES0_E"}
 // CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooES0_S0_E"}
-// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooEE"}
-// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooES0_E"}
-// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooES0_S0_E"}
+// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooEE"}
+// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooES0_E"}
+// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooES0_S0_E"}
 // CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barEE"}
 // CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barES0_E"}
 // CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo8{{[{}][{}]}}impl{{[}][}]}}3barES0_S0_E"}
diff --git a/tests/codegen/vtable-loads.rs b/tests/codegen/vtable-loads.rs
new file mode 100644
index 00000000000..1dd6ca51063
--- /dev/null
+++ b/tests/codegen/vtable-loads.rs
@@ -0,0 +1,16 @@
+//@ compile-flags: -O
+
+#![crate_type = "lib"]
+
+// 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-NEXT: tail call void %1
+    // CHECK-NOT: load ptr
+    x();
+    for _ in 0..100 {
+        // CHECK: tail call void %1
+        x();
+    }
+}