summaryrefslogtreecommitdiffstats
path: root/tests/codegen
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/codegen
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/array-codegen.rs35
-rw-r--r--tests/codegen/array-map.rs11
-rw-r--r--tests/codegen/autovectorize-f32x4.rs7
-rw-r--r--tests/codegen/box-maybe-uninit-llvm14.rs2
-rw-r--r--tests/codegen/box-maybe-uninit.rs4
-rw-r--r--tests/codegen/call-metadata.rs2
-rw-r--r--tests/codegen/const_scalar_pair.rs10
-rw-r--r--tests/codegen/debug-column.rs4
-rw-r--r--tests/codegen/drop.rs1
-rw-r--r--tests/codegen/enum-debug-niche-2.rs4
-rw-r--r--tests/codegen/enum-u128.rs27
-rw-r--r--tests/codegen/external-no-mangle-statics.rs32
-rw-r--r--tests/codegen/intrinsics/transmute.rs75
-rw-r--r--tests/codegen/issues/issue-105386-ub-in-debuginfo.rs7
-rw-r--r--tests/codegen/issues/issue-111603.rs12
-rw-r--r--tests/codegen/issues/issue-114312.rs27
-rw-r--r--tests/codegen/issues/issue-86106.rs4
-rw-r--r--tests/codegen/link_section.rs8
-rw-r--r--tests/codegen/mem-replace-simple-type.rs20
-rw-r--r--tests/codegen/mir-inlined-line-numbers.rs2
-rw-r--r--tests/codegen/naked-nocoverage.rs2
-rw-r--r--tests/codegen/naked-noinline.rs4
-rw-r--r--tests/codegen/personality_lifetimes.rs1
-rw-r--r--tests/codegen/ptr-read-metadata.rs16
-rw-r--r--tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs20
-rw-r--r--tests/codegen/sanitizer-safestack-attr-check.rs11
-rw-r--r--tests/codegen/slice-iter-fold.rs14
-rw-r--r--tests/codegen/stack-protector.rs36
-rw-r--r--tests/codegen/swap-simd-types.rs9
-rw-r--r--tests/codegen/swap-small-types.rs40
-rw-r--r--tests/codegen/tuple-layout-opt.rs12
-rw-r--r--tests/codegen/unchecked_shifts.rs4
-rw-r--r--tests/codegen/union-abi.rs20
-rw-r--r--tests/codegen/unwind-abis/c-unwind-abi.rs1
-rw-r--r--tests/codegen/unwind-abis/cdecl-unwind-abi.rs1
-rw-r--r--tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs1
-rw-r--r--tests/codegen/unwind-abis/system-unwind-abi.rs1
-rw-r--r--tests/codegen/unwind-extern-exports.rs1
-rw-r--r--tests/codegen/unwind-extern-imports.rs1
-rw-r--r--tests/codegen/vec-shrink-panik.rs9
40 files changed, 383 insertions, 115 deletions
diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs
new file mode 100644
index 000000000..98488eb92
--- /dev/null
+++ b/tests/codegen/array-codegen.rs
@@ -0,0 +1,35 @@
+// compile-flags: -O -C no-prepopulate-passes
+// min-llvm-version: 15.0 (for opaque pointers)
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @array_load
+#[no_mangle]
+pub fn array_load(a: &[u8; 4]) -> [u8; 4] {
+ // CHECK: %0 = alloca [4 x i8], align 1
+ // CHECK: %[[TEMP1:.+]] = load <4 x i8>, ptr %a, align 1
+ // CHECK: store <4 x i8> %[[TEMP1]], ptr %0, align 1
+ // CHECK: %[[TEMP2:.+]] = load i32, ptr %0, align 1
+ // CHECK: ret i32 %[[TEMP2]]
+ *a
+}
+
+// CHECK-LABEL: @array_store
+#[no_mangle]
+pub fn array_store(a: [u8; 4], p: &mut [u8; 4]) {
+ // CHECK: %a = alloca [4 x i8]
+ // CHECK: %[[TEMP:.+]] = load <4 x i8>, ptr %a, align 1
+ // CHECK-NEXT: store <4 x i8> %[[TEMP]], ptr %p, align 1
+ *p = a;
+}
+
+// CHECK-LABEL: @array_copy
+#[no_mangle]
+pub fn array_copy(a: &[u8; 4], p: &mut [u8; 4]) {
+ // CHECK: %[[LOCAL:.+]] = alloca [4 x i8], align 1
+ // CHECK: %[[TEMP1:.+]] = load <4 x i8>, ptr %a, align 1
+ // CHECK: store <4 x i8> %[[TEMP1]], ptr %[[LOCAL]], align 1
+ // CHECK: %[[TEMP2:.+]] = load <4 x i8>, ptr %[[LOCAL]], align 1
+ // CHECK: store <4 x i8> %[[TEMP2]], ptr %p, align 1
+ *p = *a;
+}
diff --git a/tests/codegen/array-map.rs b/tests/codegen/array-map.rs
index 3706ddf99..24f3f43d0 100644
--- a/tests/codegen/array-map.rs
+++ b/tests/codegen/array-map.rs
@@ -4,7 +4,6 @@
// ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"]
-#![feature(array_zip)]
// CHECK-LABEL: @short_integer_map
#[no_mangle]
@@ -16,16 +15,6 @@ pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] {
x.map(|x| 2 * x + 1)
}
-// CHECK-LABEL: @short_integer_zip_map
-#[no_mangle]
-pub fn short_integer_zip_map(x: [u32; 8], y: [u32; 8]) -> [u32; 8] {
- // CHECK: %[[A:.+]] = load <8 x i32>
- // CHECK: %[[B:.+]] = load <8 x i32>
- // CHECK: sub <8 x i32> %[[B]], %[[A]]
- // CHECK: store <8 x i32>
- x.zip(y).map(|(x, y)| x - y)
-}
-
// This test is checking that LLVM can SRoA away a bunch of the overhead,
// like fully moving the iterators to registers. Notably, previous implementations
// of `map` ended up `alloca`ing the whole `array::IntoIterator`, meaning both a
diff --git a/tests/codegen/autovectorize-f32x4.rs b/tests/codegen/autovectorize-f32x4.rs
index 9ecea53f1..54392be70 100644
--- a/tests/codegen/autovectorize-f32x4.rs
+++ b/tests/codegen/autovectorize-f32x4.rs
@@ -1,7 +1,6 @@
// compile-flags: -C opt-level=3 -Z merge-functions=disabled
// only-x86_64
#![crate_type = "lib"]
-#![feature(array_zip)]
// CHECK-LABEL: @auto_vectorize_direct
#[no_mangle]
@@ -32,12 +31,12 @@ pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
c
}
-// CHECK-LABEL: @auto_vectorize_array_zip_map
+// CHECK-LABEL: @auto_vectorize_array_from_fn
#[no_mangle]
-pub fn auto_vectorize_array_zip_map(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
+pub fn auto_vectorize_array_from_fn(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
- a.zip(b).map(|(a, b)| a + b)
+ std::array::from_fn(|i| a[i] + b[i])
}
diff --git a/tests/codegen/box-maybe-uninit-llvm14.rs b/tests/codegen/box-maybe-uninit-llvm14.rs
index b0c88f76c..c9f88fb3f 100644
--- a/tests/codegen/box-maybe-uninit-llvm14.rs
+++ b/tests/codegen/box-maybe-uninit-llvm14.rs
@@ -31,4 +31,4 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
// from the CHECK-NOT above. We don't check the attributes here because we can't rely
// on all of them being set until LLVM 15.
-// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef)
+// CHECK: declare {{(dso_local )?}}noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef)
diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-maybe-uninit.rs
index 2f8896699..5c08b5832 100644
--- a/tests/codegen/box-maybe-uninit.rs
+++ b/tests/codegen/box-maybe-uninit.rs
@@ -28,6 +28,6 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
// 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 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 @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]]
-// CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} }
+// CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) {{(uwtable )?}}"alloc-family"="__rust_alloc" {{.*}} }
diff --git a/tests/codegen/call-metadata.rs b/tests/codegen/call-metadata.rs
index 1c30c08d3..07cc0c963 100644
--- a/tests/codegen/call-metadata.rs
+++ b/tests/codegen/call-metadata.rs
@@ -6,7 +6,7 @@
#![crate_type = "lib"]
pub fn test() {
- // CHECK: call noundef i8 @some_true(), !range [[R0:![0-9]+]]
+ // CHECK: call noundef i8 @some_true(){{( #[0-9]+)?}}, !range [[R0:![0-9]+]]
// CHECK: [[R0]] = !{i8 0, i8 3}
some_true();
}
diff --git a/tests/codegen/const_scalar_pair.rs b/tests/codegen/const_scalar_pair.rs
new file mode 100644
index 000000000..aa4cf7a64
--- /dev/null
+++ b/tests/codegen/const_scalar_pair.rs
@@ -0,0 +1,10 @@
+// compile-flags: --crate-type=lib -Copt-level=0 -Zmir-opt-level=0 -C debuginfo=2
+
+#![feature(inline_const)]
+
+// 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) {
+ // CHECK: ret { i32, i32 } { i32 1, i32 2 }
+ const { (1, 2) }
+}
diff --git a/tests/codegen/debug-column.rs b/tests/codegen/debug-column.rs
index e61642b8e..f3b19a2eb 100644
--- a/tests/codegen/debug-column.rs
+++ b/tests/codegen/debug-column.rs
@@ -6,11 +6,11 @@
fn main() {
unsafe {
// Column numbers are 1-based. Regression test for #65437.
- // CHECK: call void @giraffe(), !dbg [[A:!.*]]
+ // CHECK: call void @giraffe(){{( #[0-9]+)?}}, !dbg [[A:!.*]]
giraffe();
// Column numbers use byte offests. Regression test for #67360
- // CHECK: call void @turtle(), !dbg [[B:!.*]]
+ // CHECK: call void @turtle(){{( #[0-9]+)?}}, !dbg [[B:!.*]]
/* ż */ turtle();
// CHECK: [[A]] = !DILocation(line: 10, column: 9,
diff --git a/tests/codegen/drop.rs b/tests/codegen/drop.rs
index 994028271..3615ef47b 100644
--- a/tests/codegen/drop.rs
+++ b/tests/codegen/drop.rs
@@ -1,4 +1,5 @@
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind - this test verifies the amount of drop calls when unwinding is used
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
diff --git a/tests/codegen/enum-debug-niche-2.rs b/tests/codegen/enum-debug-niche-2.rs
index 9c72ad9d2..4b607d505 100644
--- a/tests/codegen/enum-debug-niche-2.rs
+++ b/tests/codegen/enum-debug-niche-2.rs
@@ -7,8 +7,8 @@
// compile-flags: -g -C no-prepopulate-passes
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
-// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}}
-// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}
#![feature(never_type)]
diff --git a/tests/codegen/enum-u128.rs b/tests/codegen/enum-u128.rs
new file mode 100644
index 000000000..f50d360ac
--- /dev/null
+++ b/tests/codegen/enum-u128.rs
@@ -0,0 +1,27 @@
+// This tests that debug info for "c-like" 128bit enums is properly emitted.
+// This is ignored for the fallback mode on MSVC due to problems with PDB.
+
+//
+// ignore-msvc
+
+// compile-flags: -g -C no-prepopulate-passes
+
+// CHECK-LABEL: @main
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "Foo",{{.*}}flags: DIFlagEnumClass,{{.*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "Lo",{{.*}}value: 0,{{.*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "Hi",{{.*}}value: 18446744073709551616,{{.*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "Bar",{{.*}}value: 18446745000000000123,{{.*}}
+
+#![allow(incomplete_features)]
+#![feature(repr128)]
+
+#[repr(u128)]
+pub enum Foo {
+ Lo,
+ Hi = 1 << 64,
+ Bar = 18_446_745_000_000_000_123,
+}
+
+pub fn main() {
+ let foo = Foo::Bar;
+}
diff --git a/tests/codegen/external-no-mangle-statics.rs b/tests/codegen/external-no-mangle-statics.rs
index c6ecb7aa9..48023a2a9 100644
--- a/tests/codegen/external-no-mangle-statics.rs
+++ b/tests/codegen/external-no-mangle-statics.rs
@@ -6,72 +6,72 @@
// `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
// definitions
-// CHECK: @A = local_unnamed_addr constant
+// CHECK: @A = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
static A: u8 = 0;
-// CHECK: @B = local_unnamed_addr global
+// CHECK: @B = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
static mut B: u8 = 0;
-// CHECK: @C = local_unnamed_addr constant
+// CHECK: @C = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
pub static C: u8 = 0;
-// CHECK: @D = local_unnamed_addr global
+// CHECK: @D = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
pub static mut D: u8 = 0;
mod private {
- // CHECK: @E = local_unnamed_addr constant
+ // CHECK: @E = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
static E: u8 = 0;
- // CHECK: @F = local_unnamed_addr global
+ // CHECK: @F = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
static mut F: u8 = 0;
- // CHECK: @G = local_unnamed_addr constant
+ // CHECK: @G = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
pub static G: u8 = 0;
- // CHECK: @H = local_unnamed_addr global
+ // CHECK: @H = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
pub static mut H: u8 = 0;
}
const HIDDEN: () = {
- // CHECK: @I = local_unnamed_addr constant
+ // CHECK: @I = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
static I: u8 = 0;
- // CHECK: @J = local_unnamed_addr global
+ // CHECK: @J = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
static mut J: u8 = 0;
- // CHECK: @K = local_unnamed_addr constant
+ // CHECK: @K = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
pub static K: u8 = 0;
- // CHECK: @L = local_unnamed_addr global
+ // CHECK: @L = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
pub static mut L: u8 = 0;
};
fn x() {
- // CHECK: @M = local_unnamed_addr constant
+ // CHECK: @M = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
static M: fn() = x;
- // CHECK: @N = local_unnamed_addr global
+ // CHECK: @N = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
static mut N: u8 = 0;
- // CHECK: @O = local_unnamed_addr constant
+ // CHECK: @O = {{(dso_local )?}}local_unnamed_addr constant
#[no_mangle]
pub static O: u8 = 0;
- // CHECK: @P = local_unnamed_addr global
+ // CHECK: @P = {{(dso_local )?}}local_unnamed_addr global
#[no_mangle]
pub static mut P: u8 = 0;
}
diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs
index 664e697c2..fe4249400 100644
--- a/tests/codegen/intrinsics/transmute.rs
+++ b/tests/codegen/intrinsics/transmute.rs
@@ -14,10 +14,10 @@ use std::intrinsics::{transmute, transmute_unchecked};
// Some of these need custom MIR to not get removed by MIR optimizations.
use std::intrinsics::mir::*;
-enum Never {}
+pub enum ZstNever {}
#[repr(align(2))]
-pub struct BigNever(Never, u16, Never);
+pub struct BigNever(ZstNever, u16, ZstNever);
#[repr(align(8))]
pub struct Scalar64(i64);
@@ -56,11 +56,13 @@ pub unsafe fn check_bigger_array(x: [u32; 3]) -> [u32; 7] {
transmute_unchecked(x)
}
-// CHECK-LABEL: @check_to_uninhabited(
+// CHECK-LABEL: @check_to_empty_array(
#[no_mangle]
#[custom_mir(dialect = "runtime", phase = "optimized")]
-pub unsafe fn check_to_uninhabited(x: u16) -> BigNever {
+pub unsafe fn check_to_empty_array(x: [u32; 5]) -> [u32; 0] {
+ // CHECK-NOT: trap
// CHECK: call void @llvm.trap
+ // CHECK-NOT: trap
mir!{
{
RET = CastTransmute(x);
@@ -69,6 +71,37 @@ pub unsafe fn check_to_uninhabited(x: u16) -> BigNever {
}
}
+// CHECK-LABEL: @check_from_empty_array(
+#[no_mangle]
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub unsafe fn check_from_empty_array(x: [u32; 0]) -> [u32; 5] {
+ // CHECK-NOT: trap
+ // CHECK: call void @llvm.trap
+ // CHECK-NOT: trap
+ mir!{
+ {
+ RET = CastTransmute(x);
+ Return()
+ }
+ }
+}
+
+// CHECK-LABEL: @check_to_uninhabited(
+#[no_mangle]
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub unsafe fn check_to_uninhabited(x: u16) {
+ // CHECK-NOT: trap
+ // CHECK: call void @llvm.trap
+ // CHECK-NOT: trap
+ mir!{
+ let temp: BigNever;
+ {
+ temp = CastTransmute(x);
+ Return()
+ }
+ }
+}
+
// CHECK-LABEL: @check_from_uninhabited(
#[no_mangle]
#[custom_mir(dialect = "runtime", phase = "optimized")]
@@ -366,6 +399,40 @@ pub unsafe fn check_issue_109992(x: ()) -> [(); 1] {
}
}
+// CHECK-LABEL: @check_unit_to_never(
+#[no_mangle]
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub unsafe fn check_unit_to_never(x: ()) {
+ // This uses custom MIR to avoid MIR optimizations having removed ZST ops.
+
+ // CHECK-NOT: trap
+ // CHECK: call void @llvm.trap
+ // CHECK-NOT: trap
+ mir!{
+ let temp: ZstNever;
+ {
+ temp = CastTransmute(x);
+ Return()
+ }
+ }
+}
+
+// CHECK-LABEL: @check_unit_from_never(
+#[no_mangle]
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub unsafe fn check_unit_from_never(x: ZstNever) -> () {
+ // This uses custom MIR to avoid MIR optimizations having removed ZST ops.
+
+ // CHECK: start
+ // CHECK-NEXT: ret void
+ mir!{
+ {
+ RET = CastTransmute(x);
+ Return()
+ }
+ }
+}
+
// CHECK-LABEL: @check_maybe_uninit_pair(i16 %x.0, i64 %x.1)
#[no_mangle]
pub unsafe fn check_maybe_uninit_pair(
diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
index 2ee4d7cca..6e0eacfe4 100644
--- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
+++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
@@ -1,4 +1,5 @@
-// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes
+// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates
+// MIR SROA will decompose the closure
// min-llvm-version: 15.0 # this test uses opaque pointer notation
#![feature(stmt_expr_attributes)]
@@ -15,8 +16,8 @@ pub fn outer_function(x: S, y: S) -> usize {
// Check that we do not attempt to load from the spilled arg before it is assigned to
// when generating debuginfo.
// CHECK-LABEL: @outer_function
-// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]"
-// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]]
+// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:10:23: 10:25]"
+// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:10:23: 10:25]", ptr [[spill]]
// CHECK-NOT: [[load:%.*]] = load ptr, ptr
// CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]])
// CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]]
diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs
index 90b3c314d..06429ed3f 100644
--- a/tests/codegen/issues/issue-111603.rs
+++ b/tests/codegen/issues/issue-111603.rs
@@ -5,6 +5,18 @@
use std::sync::Arc;
+// CHECK-LABEL: @new_from_array
+#[no_mangle]
+pub fn new_from_array(x: u64) -> Arc<[u64]> {
+ // Ensure that we only generate one alloca for the array.
+
+ // CHECK: alloca
+ // CHECK-SAME: [1000 x i64]
+ // CHECK-NOT: alloca
+ let array = [x; 1000];
+ Arc::new(array)
+}
+
// CHECK-LABEL: @new_uninit
#[no_mangle]
pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> {
diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs
new file mode 100644
index 000000000..28b029a8b
--- /dev/null
+++ b/tests/codegen/issues/issue-114312.rs
@@ -0,0 +1,27 @@
+// compile-flags: -O
+// min-system-llvm-version: 17
+// only-x86_64-unknown-linux-gnu
+
+// We want to check that this function does not mis-optimize to loop jumping.
+
+#![crate_type = "lib"]
+
+#[repr(C)]
+pub enum Expr {
+ Sum,
+ // must have more than usize data
+ Sub(usize, u8),
+}
+
+#[no_mangle]
+pub extern "C" fn issue_114312(expr: Expr) {
+ // CHECK-LABEL: @issue_114312(
+ // CHECK-NOT: readonly
+ // CHECK-SAME: byval
+ // CHECK-NEXT: start:
+ // CHECK-NEXT: ret void
+ match expr {
+ Expr::Sum => {}
+ Expr::Sub(_, _) => issue_114312(Expr::Sum),
+ }
+}
diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs
index c0be7fab2..be5034dcf 100644
--- a/tests/codegen/issues/issue-86106.rs
+++ b/tests/codegen/issues/issue-86106.rs
@@ -7,7 +7,7 @@
#![crate_type = "lib"]
-// CHECK-LABEL: define void @string_new
+// CHECK-LABEL: define {{(dso_local )?}}void @string_new
#[no_mangle]
pub fn string_new() -> String {
// CHECK: store ptr inttoptr
@@ -17,7 +17,7 @@ pub fn string_new() -> String {
String::new()
}
-// CHECK-LABEL: define void @empty_to_string
+// CHECK-LABEL: define {{(dso_local )?}}void @empty_to_string
#[no_mangle]
pub fn empty_to_string() -> String {
// CHECK: store ptr inttoptr
diff --git a/tests/codegen/link_section.rs b/tests/codegen/link_section.rs
index 88b8692b0..2b26b604a 100644
--- a/tests/codegen/link_section.rs
+++ b/tests/codegen/link_section.rs
@@ -3,7 +3,7 @@
#![crate_type = "lib"]
-// CHECK: @VAR1 = constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one"
+// CHECK: @VAR1 = {{(dso_local )?}}constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one"
#[no_mangle]
#[link_section = ".test_one"]
#[cfg(target_endian = "little")]
@@ -19,17 +19,17 @@ pub enum E {
B(f32)
}
-// CHECK: @VAR2 = constant {{.*}}, section ".test_two"
+// CHECK: @VAR2 = {{(dso_local )?}}constant {{.*}}, section ".test_two"
#[no_mangle]
#[link_section = ".test_two"]
pub static VAR2: E = E::A(666);
-// CHECK: @VAR3 = constant {{.*}}, section ".test_three"
+// CHECK: @VAR3 = {{(dso_local )?}}constant {{.*}}, section ".test_three"
#[no_mangle]
#[link_section = ".test_three"]
pub static VAR3: E = E::B(1.);
-// CHECK: define void @fn1() {{.*}} section ".test_four" {
+// CHECK: define {{(dso_local )?}}void @fn1() {{.*}} section ".test_four" {
#[no_mangle]
#[link_section = ".test_four"]
pub fn fn1() {}
diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs
index 4253ef136..751aeaa2b 100644
--- a/tests/codegen/mem-replace-simple-type.rs
+++ b/tests/codegen/mem-replace-simple-type.rs
@@ -32,3 +32,23 @@ pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str {
// CHECK: ret { ptr, i64 } %[[P2]]
std::mem::replace(r, v)
}
+
+#[no_mangle]
+// CHECK-LABEL: @replace_short_array_3(
+pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] {
+ // CHECK-NOT: alloca
+ // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %r, i64 12, i1 false)
+ // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 12, i1 false)
+ std::mem::replace(r, v)
+}
+
+#[no_mangle]
+// CHECK-LABEL: @replace_short_array_4(
+pub fn replace_short_array_4(r: &mut [u32; 4], v: [u32; 4]) -> [u32; 4] {
+ // CHECK-NOT: alloca
+ // CHECK: %[[R:.+]] = load <4 x i32>, ptr %r, align 4
+ // CHECK: store <4 x i32> %[[R]], ptr %0
+ // CHECK: %[[V:.+]] = load <4 x i32>, ptr %v, align 4
+ // CHECK: store <4 x i32> %[[V]], ptr %r
+ std::mem::replace(r, v)
+}
diff --git a/tests/codegen/mir-inlined-line-numbers.rs b/tests/codegen/mir-inlined-line-numbers.rs
index 19d83f0ee..d13527b95 100644
--- a/tests/codegen/mir-inlined-line-numbers.rs
+++ b/tests/codegen/mir-inlined-line-numbers.rs
@@ -19,7 +19,7 @@ pub fn example() {
}
// CHECK-LABEL: @example
-// CHECK: tail call void @bar(), !dbg [[DBG_ID:![0-9]+]]
+// CHECK: tail call void @bar(){{( #[0-9]+)?}}, !dbg [[DBG_ID:![0-9]+]]
// CHECK: [[DBG_ID]] = !DILocation(line: 7,
// CHECK-SAME: inlinedAt: [[INLINE_ID:![0-9]+]])
// CHECK: [[INLINE_ID]] = !DILocation(line: 18,
diff --git a/tests/codegen/naked-nocoverage.rs b/tests/codegen/naked-nocoverage.rs
index 91a6260bf..3c755e49c 100644
--- a/tests/codegen/naked-nocoverage.rs
+++ b/tests/codegen/naked-nocoverage.rs
@@ -11,7 +11,7 @@ use std::arch::asm;
#[naked]
#[no_mangle]
pub unsafe extern "C" fn f() {
- // CHECK: define void @f()
+ // CHECK: define {{(dso_local )?}}void @f()
// CHECK-NEXT: start:
// CHECK-NEXT: call void asm
// CHECK-NEXT: unreachable
diff --git a/tests/codegen/naked-noinline.rs b/tests/codegen/naked-noinline.rs
index c0ac69f4e..5cfb500c0 100644
--- a/tests/codegen/naked-noinline.rs
+++ b/tests/codegen/naked-noinline.rs
@@ -12,7 +12,7 @@ use std::arch::asm;
pub unsafe extern "C" fn f() {
// Check that f has naked and noinline attributes.
//
- // CHECK: define void @f() unnamed_addr [[ATTR:#[0-9]+]]
+ // CHECK: define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]]
// CHECK-NEXT: start:
// CHECK-NEXT: call void asm
asm!("", options(noreturn));
@@ -22,7 +22,7 @@ pub unsafe extern "C" fn f() {
pub unsafe fn g() {
// Check that call to f is not inlined.
//
- // CHECK-LABEL: define void @g()
+ // CHECK-LABEL: define {{(dso_local )?}}void @g()
// CHECK-NEXT: start:
// CHECK-NEXT: call void @f()
f();
diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs
index 2104022f5..9ff7a9b3e 100644
--- a/tests/codegen/personality_lifetimes.rs
+++ b/tests/codegen/personality_lifetimes.rs
@@ -1,5 +1,6 @@
// ignore-msvc
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind
// compile-flags: -O -C no-prepopulate-passes
diff --git a/tests/codegen/ptr-read-metadata.rs b/tests/codegen/ptr-read-metadata.rs
index e1e327266..73d1db6df 100644
--- a/tests/codegen/ptr-read-metadata.rs
+++ b/tests/codegen/ptr-read-metadata.rs
@@ -9,7 +9,7 @@
use std::mem::MaybeUninit;
-// CHECK-LABEL: define noundef i8 @copy_byte(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @copy_byte(
#[no_mangle]
pub unsafe fn copy_byte(p: *const u8) -> u8 {
// CHECK-NOT: load
@@ -19,7 +19,7 @@ pub unsafe fn copy_byte(p: *const u8) -> u8 {
*p
}
-// CHECK-LABEL: define noundef i8 @read_byte(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @read_byte(
#[no_mangle]
pub unsafe fn read_byte(p: *const u8) -> u8 {
// CHECK-NOT: load
@@ -29,7 +29,7 @@ pub unsafe fn read_byte(p: *const u8) -> u8 {
p.read()
}
-// CHECK-LABEL: define i8 @read_byte_maybe_uninit(
+// CHECK-LABEL: define {{(dso_local )?}}i8 @read_byte_maybe_uninit(
#[no_mangle]
pub unsafe fn read_byte_maybe_uninit(p: *const MaybeUninit<u8>) -> MaybeUninit<u8> {
// CHECK-NOT: load
@@ -39,7 +39,7 @@ pub unsafe fn read_byte_maybe_uninit(p: *const MaybeUninit<u8>) -> MaybeUninit<u
p.read()
}
-// CHECK-LABEL: define noundef i8 @read_byte_assume_init(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @read_byte_assume_init(
#[no_mangle]
pub unsafe fn read_byte_assume_init(p: &MaybeUninit<u8>) -> u8 {
// CHECK-NOT: load
@@ -49,7 +49,7 @@ pub unsafe fn read_byte_assume_init(p: &MaybeUninit<u8>) -> u8 {
p.assume_init_read()
}
-// CHECK-LABEL: define noundef i32 @copy_char(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @copy_char(
#[no_mangle]
pub unsafe fn copy_char(p: *const char) -> char {
// CHECK-NOT: load
@@ -60,7 +60,7 @@ pub unsafe fn copy_char(p: *const char) -> char {
*p
}
-// CHECK-LABEL: define noundef i32 @read_char(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @read_char(
#[no_mangle]
pub unsafe fn read_char(p: *const char) -> char {
// CHECK-NOT: load
@@ -71,7 +71,7 @@ pub unsafe fn read_char(p: *const char) -> char {
p.read()
}
-// CHECK-LABEL: define i32 @read_char_maybe_uninit(
+// CHECK-LABEL: define {{(dso_local )?}}i32 @read_char_maybe_uninit(
#[no_mangle]
pub unsafe fn read_char_maybe_uninit(p: *const MaybeUninit<char>) -> MaybeUninit<char> {
// CHECK-NOT: load
@@ -82,7 +82,7 @@ pub unsafe fn read_char_maybe_uninit(p: *const MaybeUninit<char>) -> MaybeUninit
p.read()
}
-// CHECK-LABEL: define noundef i32 @read_char_assume_init(
+// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @read_char_assume_init(
#[no_mangle]
pub unsafe fn read_char_assume_init(p: &MaybeUninit<char>) -> char {
// CHECK-NOT: load
diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
index ebb26cd35..63e63c5d4 100644
--- a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
+++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
@@ -61,7 +61,19 @@ pub type Type9 = impl Send;
pub type Type10 = impl Send;
pub type Type11 = impl Send;
-pub fn fn1<'a>() {
+pub fn fn1<'a>() where
+ Type1: 'static,
+ Type2: 'static,
+ Type3: 'static,
+ Type4: 'static,
+ Type5: 'static,
+ Type6: 'static,
+ Type7: 'static,
+ Type8: 'static,
+ Type9: 'static,
+ Type10: 'static,
+ Type11: 'static,
+{
// Closure
let closure1 = || { };
let _: Type1 = closure1;
@@ -587,6 +599,6 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { }
// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"}
// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"}
// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"}
-// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE
-// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E
-// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E
+// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"}
+// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"}
+// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"}
diff --git a/tests/codegen/sanitizer-safestack-attr-check.rs b/tests/codegen/sanitizer-safestack-attr-check.rs
new file mode 100644
index 000000000..b73ed00e7
--- /dev/null
+++ b/tests/codegen/sanitizer-safestack-attr-check.rs
@@ -0,0 +1,11 @@
+// This tests that the safestack attribute is applied when enabling the safe-stack sanitizer.
+//
+// needs-sanitizer-safestack
+// compile-flags: -Zsanitizer=safestack
+
+#![crate_type = "lib"]
+
+// CHECK: ; Function Attrs:{{.*}}safestack
+pub fn tagged() {}
+
+// CHECK: attributes #0 = {{.*}}safestack
diff --git a/tests/codegen/slice-iter-fold.rs b/tests/codegen/slice-iter-fold.rs
new file mode 100644
index 000000000..9391c1761
--- /dev/null
+++ b/tests/codegen/slice-iter-fold.rs
@@ -0,0 +1,14 @@
+// ignore-debug: the debug assertions get in the way
+// compile-flags: -O
+// min-llvm-version: 16
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @slice_fold_to_last
+#[no_mangle]
+pub fn slice_fold_to_last(slice: &[i32]) -> Option<&i32> {
+ // CHECK-NOT: loop
+ // CHECK-NOT: br
+ // CHECK-NOT: call
+ // CHECK: ret
+ slice.iter().fold(None, |_, i| Some(i))
+}
diff --git a/tests/codegen/stack-protector.rs b/tests/codegen/stack-protector.rs
index a24e6f1e4..a680789af 100644
--- a/tests/codegen/stack-protector.rs
+++ b/tests/codegen/stack-protector.rs
@@ -10,25 +10,25 @@
pub fn foo() {
// CHECK: @foo() unnamed_addr #0
- // all-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
- // all-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
- // all: attributes #0 = { {{.*}} sspreq {{.*}} }
- // all-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
- // all-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}}sspstrong {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}}ssp {{.*}} }
+ // all: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}}sspstrong {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}}ssp {{.*}} }
- // strong-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
- // strong-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
- // strong: attributes #0 = { {{.*}} sspstrong {{.*}} }
- // strong-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
- // strong-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}}ssp {{.*}} }
+ // strong: attributes #0 = { {{.*}}sspstrong {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}}ssp {{.*}} }
- // basic-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
- // basic-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
- // basic: attributes #0 = { {{.*}} ssp {{.*}} }
- // basic-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
- // basic-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}}sspstrong {{.*}} }
+ // basic: attributes #0 = { {{.*}}ssp {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}}sspstrong {{.*}} }
- // none-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
- // none-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
- // none-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+ // none-NOT: attributes #0 = { {{.*}}sspreq {{.*}} }
+ // none-NOT: attributes #0 = { {{.*}}sspstrong {{.*}} }
+ // none-NOT: attributes #0 = { {{.*}}ssp {{.*}} }
}
diff --git a/tests/codegen/swap-simd-types.rs b/tests/codegen/swap-simd-types.rs
index c90b277eb..3472a42b0 100644
--- a/tests/codegen/swap-simd-types.rs
+++ b/tests/codegen/swap-simd-types.rs
@@ -30,3 +30,12 @@ pub fn swap_m256_slice(x: &mut [__m256], y: &mut [__m256]) {
x.swap_with_slice(y);
}
}
+
+// CHECK-LABEL: @swap_bytes32
+#[no_mangle]
+pub fn swap_bytes32(x: &mut [u8; 32], y: &mut [u8; 32]) {
+// CHECK-NOT: alloca
+// CHECK: load <32 x i8>{{.+}}align 1
+// CHECK: store <32 x i8>{{.+}}align 1
+ swap(x, y)
+}
diff --git a/tests/codegen/swap-small-types.rs b/tests/codegen/swap-small-types.rs
index 03e2a2327..27bc00bc3 100644
--- a/tests/codegen/swap-small-types.rs
+++ b/tests/codegen/swap-small-types.rs
@@ -1,4 +1,4 @@
-// compile-flags: -O
+// compile-flags: -O -Z merge-functions=disabled
// only-x86_64
// ignore-debug: the debug assertions get in the way
@@ -8,13 +8,43 @@ use std::mem::swap;
type RGB48 = [u16; 3];
+// CHECK-LABEL: @swap_rgb48_manually(
+#[no_mangle]
+pub fn swap_rgb48_manually(x: &mut RGB48, y: &mut RGB48) {
+ // FIXME: See #115212 for why this has an alloca again
+
+ // CHECK: alloca [3 x i16], align 2
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+
+ let temp = *x;
+ *x = *y;
+ *y = temp;
+}
+
// CHECK-LABEL: @swap_rgb48
#[no_mangle]
pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) {
- // FIXME MIR inlining messes up LLVM optimizations.
-// WOULD-CHECK-NOT: alloca
-// WOULD-CHECK: load i48
-// WOULD-CHECK: store i48
+ // FIXME: See #115212 for why this has an alloca again
+
+ // CHECK: alloca [3 x i16], align 2
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+ // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false)
+ swap(x, y)
+}
+
+type RGBA64 = [u16; 4];
+
+// CHECK-LABEL: @swap_rgba64
+#[no_mangle]
+pub fn swap_rgba64(x: &mut RGBA64, y: &mut RGBA64) {
+ // CHECK-NOT: alloca
+ // CHECK-DAG: %[[XVAL:.+]] = load <4 x i16>, ptr %x, align 2
+ // CHECK-DAG: %[[YVAL:.+]] = load <4 x i16>, ptr %y, align 2
+ // CHECK-DAG: store <4 x i16> %[[YVAL]], ptr %x, align 2
+ // CHECK-DAG: store <4 x i16> %[[XVAL]], ptr %y, align 2
swap(x, y)
}
diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs
index 35f760851..309fe1d5e 100644
--- a/tests/codegen/tuple-layout-opt.rs
+++ b/tests/codegen/tuple-layout-opt.rs
@@ -6,31 +6,31 @@
#![crate_type="lib"]
type ScalarZstLast = (u128, ());
-// CHECK: define i128 @test_ScalarZstLast(i128 %_1)
+// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstLast(i128 %_1)
#[no_mangle]
pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} }
type ScalarZstFirst = ((), u128);
-// CHECK: define i128 @test_ScalarZstFirst(i128 %_1)
+// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstFirst(i128 %_1)
#[no_mangle]
pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} }
type ScalarPairZstLast = (u8, u128, ());
-// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1)
+// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1)
#[no_mangle]
pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} }
type ScalarPairZstFirst = ((), u8, u128);
-// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1)
+// CHECK: define {{(dso_local )?}}{ i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1)
#[no_mangle]
pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} }
type ScalarPairLotsOfZsts = ((), u8, (), u128, ());
-// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1)
+// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1)
#[no_mangle]
pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} }
type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ());
-// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1)
+// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1)
#[no_mangle]
pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} }
diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs
index 60d0cb09a..0924dda08 100644
--- a/tests/codegen/unchecked_shifts.rs
+++ b/tests/codegen/unchecked_shifts.rs
@@ -8,6 +8,7 @@
// CHECK-LABEL: @unchecked_shl_unsigned_same
#[no_mangle]
pub unsafe fn unchecked_shl_unsigned_same(a: u32, b: u32) -> u32 {
+ // CHECK-NOT: assume
// CHECK-NOT: and i32
// CHECK: shl i32 %a, %b
// CHECK-NOT: and i32
@@ -30,6 +31,7 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
// CHECK-LABEL: @unchecked_shl_unsigned_bigger
#[no_mangle]
pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 {
+ // CHECK-NOT: assume
// CHECK: %[[EXT:.+]] = zext i32 %b to i64
// CHECK: shl i64 %a, %[[EXT]]
a.unchecked_shl(b)
@@ -38,6 +40,7 @@ pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 {
// CHECK-LABEL: @unchecked_shr_signed_same
#[no_mangle]
pub unsafe fn unchecked_shr_signed_same(a: i32, b: u32) -> i32 {
+ // CHECK-NOT: assume
// CHECK-NOT: and i32
// CHECK: ashr i32 %a, %b
// CHECK-NOT: and i32
@@ -60,6 +63,7 @@ pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 {
// CHECK-LABEL: @unchecked_shr_signed_bigger
#[no_mangle]
pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 {
+ // CHECK-NOT: assume
// CHECK: %[[EXT:.+]] = zext i32 %b to i64
// CHECK: ashr i64 %a, %[[EXT]]
a.unchecked_shr(b)
diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs
index c18f2a49f..8481ca8cc 100644
--- a/tests/codegen/union-abi.rs
+++ b/tests/codegen/union-abi.rs
@@ -17,60 +17,60 @@ pub struct i64x4(i64, i64, i64, i64);
#[derive(Copy, Clone)]
pub union UnionI64x4{ a:(), b: i64x4 }
-// CHECK: define void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1)
+// CHECK: define {{(dso_local )?}}void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1)
#[no_mangle]
pub fn test_UnionI64x4(_: UnionI64x4) { loop {} }
pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 }
-// CHECK: define void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1)
+// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1)
#[no_mangle]
pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} }
pub union UnionI64x4I64{ a: i64x4, b: i64 }
-// CHECK: define void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1)
+// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1)
#[no_mangle]
pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} }
pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) }
-// CHECK: define void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1)
+// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1)
#[no_mangle]
pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} }
pub union UnionF32{a:f32}
-// CHECK: define float @test_UnionF32(float %_1)
+// CHECK: define {{(dso_local )?}}float @test_UnionF32(float %_1)
#[no_mangle]
pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
pub union UnionF32F32{a:f32, b:f32}
-// CHECK: define float @test_UnionF32F32(float %_1)
+// CHECK: define {{(dso_local )?}}float @test_UnionF32F32(float %_1)
#[no_mangle]
pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} }
pub union UnionF32U32{a:f32, b:u32}
-// CHECK: define i32 @test_UnionF32U32(i32{{( %0)?}})
+// CHECK: define {{(dso_local )?}}i32 @test_UnionF32U32(i32{{( %0)?}})
#[no_mangle]
pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} }
pub union UnionU128{a:u128}
-// CHECK: define i128 @test_UnionU128(i128 %_1)
+// CHECK: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1)
#[no_mangle]
pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} }
#[repr(C)]
pub union CUnionU128{a:u128}
-// CHECK: define void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1)
+// CHECK: define {{(dso_local )?}}void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1)
#[no_mangle]
pub fn test_CUnionU128(_: CUnionU128) { loop {} }
pub union UnionBool { b:bool }
-// CHECK: define noundef zeroext i1 @test_UnionBool(i8 %b)
+// CHECK: define {{(dso_local )?}}noundef zeroext i1 @test_UnionBool(i8 %b)
#[no_mangle]
pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } }
// CHECK: %0 = trunc i8 %b to i1
diff --git a/tests/codegen/unwind-abis/c-unwind-abi.rs b/tests/codegen/unwind-abis/c-unwind-abi.rs
index e258dbcac..fa5b6bad7 100644
--- a/tests/codegen/unwind-abis/c-unwind-abi.rs
+++ b/tests/codegen/unwind-abis/c-unwind-abi.rs
@@ -1,4 +1,5 @@
// compile-flags: -C opt-level=0
+// needs-unwind
// Test that `nounwind` attributes are correctly applied to exported `C` and `C-unwind` extern
// functions. `C-unwind` functions MUST NOT have this attribute. We disable optimizations above
diff --git a/tests/codegen/unwind-abis/cdecl-unwind-abi.rs b/tests/codegen/unwind-abis/cdecl-unwind-abi.rs
index 19a722883..64746d321 100644
--- a/tests/codegen/unwind-abis/cdecl-unwind-abi.rs
+++ b/tests/codegen/unwind-abis/cdecl-unwind-abi.rs
@@ -1,4 +1,5 @@
// compile-flags: -C opt-level=0
+// needs-unwind
// Test that `nounwind` attributes are correctly applied to exported `cdecl` and
// `cdecl-unwind` extern functions. `cdecl-unwind` functions MUST NOT have this attribute. We
diff --git a/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs b/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs
index c1c5bbdda..dc3911cd4 100644
--- a/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs
+++ b/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs
@@ -1,5 +1,6 @@
// compile-flags: -C opt-level=0
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind
#![crate_type = "lib"]
diff --git a/tests/codegen/unwind-abis/system-unwind-abi.rs b/tests/codegen/unwind-abis/system-unwind-abi.rs
index 2591c1d48..f274a33b0 100644
--- a/tests/codegen/unwind-abis/system-unwind-abi.rs
+++ b/tests/codegen/unwind-abis/system-unwind-abi.rs
@@ -1,4 +1,5 @@
// compile-flags: -C opt-level=0
+// needs-unwind
// Test that `nounwind` attributes are correctly applied to exported `system` and `system-unwind`
// extern functions. `system-unwind` functions MUST NOT have this attribute. We disable
diff --git a/tests/codegen/unwind-extern-exports.rs b/tests/codegen/unwind-extern-exports.rs
index 6ac3c079f..4e1e719d5 100644
--- a/tests/codegen/unwind-extern-exports.rs
+++ b/tests/codegen/unwind-extern-exports.rs
@@ -1,5 +1,6 @@
// compile-flags: -C opt-level=0
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind
#![crate_type = "lib"]
#![feature(c_unwind)]
diff --git a/tests/codegen/unwind-extern-imports.rs b/tests/codegen/unwind-extern-imports.rs
index e33e3e805..260dcc628 100644
--- a/tests/codegen/unwind-extern-imports.rs
+++ b/tests/codegen/unwind-extern-imports.rs
@@ -1,5 +1,6 @@
// compile-flags: -C no-prepopulate-passes
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind
#![crate_type = "lib"]
#![feature(c_unwind)]
diff --git a/tests/codegen/vec-shrink-panik.rs b/tests/codegen/vec-shrink-panik.rs
index 88b7edff2..14fef4e2c 100644
--- a/tests/codegen/vec-shrink-panik.rs
+++ b/tests/codegen/vec-shrink-panik.rs
@@ -5,6 +5,7 @@
// [new]min-llvm-version: 17
// compile-flags: -O
// ignore-debug: the debug assertions get in the way
+// needs-unwind
#![crate_type = "lib"]
#![feature(shrink_to)]
@@ -37,14 +38,6 @@ pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
#[no_mangle]
pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
// CHECK-NOT: panic
-
- // Call to panic_cannot_unwind in case of double-panic is expected,
- // on LLVM 16 and older, but other panics are not.
- // old: filter
- // old-NEXT: ; call core::panicking::panic_cannot_unwind
- // old-NEXT: panic_cannot_unwind
-
- // CHECK-NOT: panic
iter.iter().copied().collect()
}