about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/array-codegen.rs22
-rw-r--r--tests/codegen/array-optimized.rs33
-rw-r--r--tests/codegen/asm-sanitize-llvm.rs2
-rw-r--r--tests/codegen/async-fn-debug-awaitee-field.rs4
-rw-r--r--tests/codegen/async-fn-debug-msvc.rs2
-rw-r--r--tests/codegen/char-ascii-branchless.rs47
-rw-r--r--tests/codegen/coroutine-debug-msvc.rs (renamed from tests/codegen/generator-debug-msvc.rs)12
-rw-r--r--tests/codegen/coroutine-debug.rs (renamed from tests/codegen/generator-debug.rs)14
-rw-r--r--tests/codegen/debug-fndef-size.rs18
-rw-r--r--tests/codegen/debug-linkage-name.rs4
-rw-r--r--tests/codegen/default-requires-uwtable.rs2
-rw-r--r--tests/codegen/drop.rs2
-rw-r--r--tests/codegen/force-frame-pointers.rs2
-rw-r--r--tests/codegen/force-unwind-tables.rs2
-rw-r--r--tests/codegen/inline-function-args-debug-info.rs5
-rw-r--r--tests/codegen/instrument-coverage-off.rs23
-rw-r--r--tests/codegen/instrument-coverage.rs9
-rw-r--r--tests/codegen/instrument-mcount.rs2
-rw-r--r--tests/codegen/instrument-xray/basic.rs2
-rw-r--r--tests/codegen/instrument-xray/options-combine.rs6
-rw-r--r--tests/codegen/instrument-xray/options-override.rs4
-rw-r--r--tests/codegen/issue-97217.rs22
-rw-r--r--tests/codegen/panic-unwind-default-uwtable.rs2
-rw-r--r--tests/codegen/personality_lifetimes.rs2
-rw-r--r--tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs2
-rw-r--r--tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs2
-rw-r--r--tests/codegen/sanitizer/cfi-generalize-pointers.rs2
-rw-r--r--tests/codegen/sanitizer/cfi-normalize-integers.rs2
-rw-r--r--tests/codegen/sanitizer/kasan-emits-instrumentation.rs2
-rw-r--r--tests/codegen/sanitizer/memtag-attr-check.rs2
-rw-r--r--tests/codegen/sanitizer/no-sanitize.rs2
-rw-r--r--tests/codegen/sanitizer/safestack-attr-check.rs2
-rw-r--r--tests/codegen/simd/simd-wide-sum.rs26
-rw-r--r--tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs2
-rw-r--r--tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs2
-rw-r--r--tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs2
-rw-r--r--tests/codegen/target-cpu-on-functions.rs3
-rw-r--r--tests/codegen/target-feature-inline-closure.rs4
-rw-r--r--tests/codegen/tied-features-strength.rs8
-rw-r--r--tests/codegen/tune-cpu-on-functions.rs2
-rw-r--r--tests/codegen/unchecked_shifts.rs2
-rw-r--r--tests/codegen/unwind-landingpad-cold.rs16
-rw-r--r--tests/codegen/unwind-landingpad-inline.rs39
-rw-r--r--tests/codegen/vec-reserve-extend.rs14
-rw-r--r--tests/codegen/vec_pop_push_noop.rs24
45 files changed, 339 insertions, 64 deletions
diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs
index ba0d444f97e..bf5ae74679b 100644
--- a/tests/codegen/array-codegen.rs
+++ b/tests/codegen/array-codegen.rs
@@ -32,3 +32,25 @@ pub fn array_copy(a: &[u8; 4], p: &mut [u8; 4]) {
     // CHECK: store <4 x i8> %[[TEMP2]], ptr %p, align 1
     *p = *a;
 }
+
+// CHECK-LABEL: @array_copy_1_element
+#[no_mangle]
+pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) {
+    // CHECK: %[[LOCAL:.+]] = alloca [1 x i8], align 1
+    // CHECK: %[[TEMP1:.+]] = load i8, ptr %a, align 1
+    // CHECK: store i8 %[[TEMP1]], ptr %[[LOCAL]], align 1
+    // CHECK: %[[TEMP2:.+]] = load i8, ptr %[[LOCAL]], align 1
+    // CHECK: store i8 %[[TEMP2]], ptr %p, align 1
+    *p = *a;
+}
+
+// CHECK-LABEL: @array_copy_2_elements
+#[no_mangle]
+pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) {
+    // CHECK: %[[LOCAL:.+]] = alloca [2 x i8], align 1
+    // CHECK: %[[TEMP1:.+]] = load <2 x i8>, ptr %a, align 1
+    // CHECK: store <2 x i8> %[[TEMP1]], ptr %[[LOCAL]], align 1
+    // CHECK: %[[TEMP2:.+]] = load <2 x i8>, ptr %[[LOCAL]], align 1
+    // CHECK: store <2 x i8> %[[TEMP2]], ptr %p, align 1
+    *p = *a;
+}
diff --git a/tests/codegen/array-optimized.rs b/tests/codegen/array-optimized.rs
new file mode 100644
index 00000000000..27448fdcfad
--- /dev/null
+++ b/tests/codegen/array-optimized.rs
@@ -0,0 +1,33 @@
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// 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: ret
+    *p = *a;
+}
+
+// CHECK-LABEL: @array_copy_2_elements
+#[no_mangle]
+pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) {
+    // CHECK-NOT: alloca
+    // CHECK: %[[TEMP:.+]] = load <2 x i8>, ptr %a, align 1
+    // CHECK: store <2 x i8> %[[TEMP]], ptr %p, align 1
+    // CHECK: ret
+    *p = *a;
+}
+
+// CHECK-LABEL: @array_copy_4_elements
+#[no_mangle]
+pub fn array_copy_4_elements(a: &[u8; 4], p: &mut [u8; 4]) {
+    // CHECK-NOT: alloca
+    // CHECK: %[[TEMP:.+]] = load <4 x i8>, ptr %a, align 1
+    // CHECK: store <4 x i8> %[[TEMP]], ptr %p, align 1
+    // CHECK: ret
+    *p = *a;
+}
diff --git a/tests/codegen/asm-sanitize-llvm.rs b/tests/codegen/asm-sanitize-llvm.rs
index 6dcacd08cac..41bed98038e 100644
--- a/tests/codegen/asm-sanitize-llvm.rs
+++ b/tests/codegen/asm-sanitize-llvm.rs
@@ -1,5 +1,5 @@
 // FIXME(nagisa): remove the flags below once all targets support `asm!`.
-// compile-flags: --target x86_64-unknown-linux-gnu
+// compile-flags: --target x86_64-unknown-linux-gnu -Copt-level=0
 // needs-llvm-components: x86
 
 // Verify we sanitize the special tokens for the LLVM inline-assembly, ensuring people won't
diff --git a/tests/codegen/async-fn-debug-awaitee-field.rs b/tests/codegen/async-fn-debug-awaitee-field.rs
index 690505fd72b..03cc46cdcde 100644
--- a/tests/codegen/async-fn-debug-awaitee-field.rs
+++ b/tests/codegen/async-fn-debug-awaitee-field.rs
@@ -1,9 +1,9 @@
-// This test makes sure that the generator field capturing the awaitee in a `.await` expression
+// This test makes sure that the coroutine field capturing the awaitee in a `.await` expression
 // is called "__awaitee" in debuginfo. This name must not be changed since debuggers and debugger
 // extensions rely on the field having this name.
 
 // ignore-tidy-linelength
-// compile-flags: -C debuginfo=2 --edition=2018
+// compile-flags: -C debuginfo=2 --edition=2018 -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/async-fn-debug-msvc.rs b/tests/codegen/async-fn-debug-msvc.rs
index 73c652c9dd1..707a0d27740 100644
--- a/tests/codegen/async-fn-debug-msvc.rs
+++ b/tests/codegen/async-fn-debug-msvc.rs
@@ -1,4 +1,4 @@
-// Verify debuginfo for generators:
+// Verify debuginfo for coroutines:
 //  - Each variant points to the file and line of its yield point
 //  - The discriminants are marked artificial
 //  - Other fields are not marked artificial
diff --git a/tests/codegen/char-ascii-branchless.rs b/tests/codegen/char-ascii-branchless.rs
new file mode 100644
index 00000000000..b612b24c7c7
--- /dev/null
+++ b/tests/codegen/char-ascii-branchless.rs
@@ -0,0 +1,47 @@
+// Checks that these functions are branchless.
+//
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @is_ascii_alphanumeric_char
+#[no_mangle]
+pub fn is_ascii_alphanumeric_char(x: char) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_alphanumeric()
+}
+
+// CHECK-LABEL: @is_ascii_alphanumeric_u8
+#[no_mangle]
+pub fn is_ascii_alphanumeric_u8(x: u8) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_alphanumeric()
+}
+
+// CHECK-LABEL: @is_ascii_hexdigit_char
+#[no_mangle]
+pub fn is_ascii_hexdigit_char(x: char) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_hexdigit()
+}
+
+// CHECK-LABEL: @is_ascii_hexdigit_u8
+#[no_mangle]
+pub fn is_ascii_hexdigit_u8(x: u8) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_hexdigit()
+}
+
+// CHECK-LABEL: @is_ascii_punctuation_char
+#[no_mangle]
+pub fn is_ascii_punctuation_char(x: char) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_punctuation()
+}
+
+// CHECK-LABEL: @is_ascii_punctuation_u8
+#[no_mangle]
+pub fn is_ascii_punctuation_u8(x: u8) -> bool {
+    // CHECK-NOT: br
+    x.is_ascii_punctuation()
+}
diff --git a/tests/codegen/generator-debug-msvc.rs b/tests/codegen/coroutine-debug-msvc.rs
index 9d70ccdef03..6d16e7576c1 100644
--- a/tests/codegen/generator-debug-msvc.rs
+++ b/tests/codegen/coroutine-debug-msvc.rs
@@ -1,4 +1,4 @@
-// Verify debuginfo for generators:
+// Verify debuginfo for coroutines:
 //  - Each variant points to the file and line of its yield point
 //  - The discriminants are marked artificial
 //  - Other fields are not marked artificial
@@ -7,10 +7,10 @@
 // compile-flags: -C debuginfo=2
 // only-msvc
 
-#![feature(generators, generator_trait)]
-use std::ops::Generator;
+#![feature(coroutines, coroutine_trait)]
+use std::ops::Coroutine;
 
-fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
+fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
     || {
         yield 0;
         let s = String::from("foo");
@@ -20,7 +20,7 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 
 // FIXME: No way to reliably check the filename.
 
-// CHECK-DAG:  [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<generator_debug_msvc::generator_test::generator_env$0>"
+// CHECK-DAG:  [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<coroutine_debug_msvc::coroutine_test::coroutine_env$0>"
 // CHECK:      {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant0", scope: [[GEN]],
 // For brevity, we only check the struct name and members of the last variant.
 // CHECK-SAME: file: [[FILE:![0-9]*]], line: 14,
@@ -55,5 +55,5 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 // CHECK-NOT: flags: DIFlagArtificial
 
 fn main() {
-    let _dummy = generator_test();
+    let _dummy = coroutine_test();
 }
diff --git a/tests/codegen/generator-debug.rs b/tests/codegen/coroutine-debug.rs
index 3ec860f2cbc..b060f3bfac7 100644
--- a/tests/codegen/generator-debug.rs
+++ b/tests/codegen/coroutine-debug.rs
@@ -1,4 +1,4 @@
-// Verify debuginfo for generators:
+// Verify debuginfo for coroutines:
 //  - Each variant points to the file and line of its yield point
 //  - The discriminants are marked artificial
 //  - Other fields are not marked artificial
@@ -7,10 +7,10 @@
 // compile-flags: -C debuginfo=2 --edition=2018
 // ignore-msvc
 
-#![feature(generators, generator_trait)]
-use std::ops::Generator;
+#![feature(coroutines, coroutine_trait)]
+use std::ops::Coroutine;
 
-fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
+fn coroutine_test() -> impl Coroutine<Yield = i32, Return = ()> {
     || {
         yield 0;
         let s = String::from("foo");
@@ -20,8 +20,8 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 
 // FIXME: No way to reliably check the filename.
 
-// CHECK-DAG:  [[GEN_FN:!.*]] = !DINamespace(name: "generator_test"
-// CHECK-DAG:  [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{generator_env#0}", scope: [[GEN_FN]]
+// CHECK-DAG:  [[GEN_FN:!.*]] = !DINamespace(name: "coroutine_test"
+// CHECK-DAG:  [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{coroutine_env#0}", scope: [[GEN_FN]]
 // CHECK:      [[VARIANT:!.*]] = !DICompositeType(tag: DW_TAG_variant_part, scope: [[GEN]],
 // CHECK-NOT:  flags: DIFlagArtificial
 // CHECK-SAME: discriminator: [[DISC:![0-9]*]]
@@ -58,5 +58,5 @@ fn generator_test() -> impl Generator<Yield = i32, Return = ()> {
 // CHECK-SAME: flags: DIFlagArtificial
 
 fn main() {
-    let _dummy = generator_test();
+    let _dummy = coroutine_test();
 }
diff --git a/tests/codegen/debug-fndef-size.rs b/tests/codegen/debug-fndef-size.rs
new file mode 100644
index 00000000000..80eb35fa32a
--- /dev/null
+++ b/tests/codegen/debug-fndef-size.rs
@@ -0,0 +1,18 @@
+// Verify that `i32::cmp` FnDef type is declared with size 0 and align 1 in LLVM debuginfo.
+// compile-flags: -O -g -Cno-prepopulate-passes
+// ignore-msvc the types are mangled differently
+
+use std::cmp::Ordering;
+
+fn foo<F: FnOnce(&i32, &i32) -> Ordering>(v1: i32, v2: i32, compare: F) -> Ordering {
+    compare(&v1, &v2)
+}
+
+pub fn main() {
+    foo(0, 1, i32::cmp);
+}
+
+// CHECK: %compare.dbg.spill = alloca {}, align 1
+// CHECK: call void @llvm.dbg.declare(metadata ptr %compare.dbg.spill, metadata ![[VAR:.*]], metadata !DIExpression()), !dbg !{{.*}}
+// CHECK: ![[TYPE:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "fn(&i32, &i32) -> core::cmp::Ordering", baseType: !{{.*}}, align: 1, dwarfAddressSpace: {{.*}})
+// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 1)
diff --git a/tests/codegen/debug-linkage-name.rs b/tests/codegen/debug-linkage-name.rs
index 9011a7da51d..9bf4d521fc0 100644
--- a/tests/codegen/debug-linkage-name.rs
+++ b/tests/codegen/debug-linkage-name.rs
@@ -1,8 +1,8 @@
 // Verifies that linkage name is omitted when it is
 // the same as variable / function name.
 //
-// compile-flags: -C no-prepopulate-passes
-// compile-flags: -C debuginfo=2
+// compile-flags: -C no-prepopulate-passes -Copt-level=0
+// compile-flags: -C debuginfo=2 -Copt-level=0
 #![crate_type = "lib"]
 
 pub mod xyz {
diff --git a/tests/codegen/default-requires-uwtable.rs b/tests/codegen/default-requires-uwtable.rs
index 5d77d3f14bb..26424f03568 100644
--- a/tests/codegen/default-requires-uwtable.rs
+++ b/tests/codegen/default-requires-uwtable.rs
@@ -1,5 +1,5 @@
 // revisions: WINDOWS ANDROID
-// compile-flags: -C panic=abort
+// compile-flags: -C panic=abort -Copt-level=0
 // [WINDOWS] compile-flags: --target=x86_64-pc-windows-msvc
 // [WINDOWS] needs-llvm-components: x86
 // [ANDROID] compile-flags: --target=armv7-linux-androideabi
diff --git a/tests/codegen/drop.rs b/tests/codegen/drop.rs
index 3615ef47b53..14b5840e2fe 100644
--- a/tests/codegen/drop.rs
+++ b/tests/codegen/drop.rs
@@ -7,10 +7,12 @@
 struct SomeUniqueName;
 
 impl Drop for SomeUniqueName {
+    #[inline(never)]
     fn drop(&mut self) {
     }
 }
 
+#[inline(never)]
 pub fn possibly_unwinding() {
 }
 
diff --git a/tests/codegen/force-frame-pointers.rs b/tests/codegen/force-frame-pointers.rs
index 637c4234654..5791ae47937 100644
--- a/tests/codegen/force-frame-pointers.rs
+++ b/tests/codegen/force-frame-pointers.rs
@@ -1,4 +1,4 @@
-// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y
+// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y -Copt-level=0
 
 #![crate_type="lib"]
 
diff --git a/tests/codegen/force-unwind-tables.rs b/tests/codegen/force-unwind-tables.rs
index 4c0a5602c6d..c904978c9ff 100644
--- a/tests/codegen/force-unwind-tables.rs
+++ b/tests/codegen/force-unwind-tables.rs
@@ -1,4 +1,4 @@
-// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y
+// compile-flags: -C no-prepopulate-passes -C force-unwind-tables=y -Copt-level=0
 
 #![crate_type="lib"]
 
diff --git a/tests/codegen/inline-function-args-debug-info.rs b/tests/codegen/inline-function-args-debug-info.rs
index e3d8caa49d4..ffae99e0f24 100644
--- a/tests/codegen/inline-function-args-debug-info.rs
+++ b/tests/codegen/inline-function-args-debug-info.rs
@@ -6,6 +6,7 @@
 
 #![crate_type = "lib"]
 
+#[inline(never)]
 pub fn outer_function(x: usize, y: usize) -> usize {
     inner_function(x, y) + 1
 }
@@ -13,8 +14,8 @@ pub fn outer_function(x: usize, y: usize) -> usize {
 #[inline]
 fn inner_function(aaaa: usize, bbbb: usize) -> usize {
     // CHECK: !DILocalVariable(name: "aaaa", arg: 1
-    // CHECK-SAME: line: 14
+    // CHECK-SAME: line: 15
     // CHECK: !DILocalVariable(name: "bbbb", arg: 2
-    // CHECK-SAME: line: 14
+    // CHECK-SAME: line: 15
     aaaa + bbbb
 }
diff --git a/tests/codegen/instrument-coverage-off.rs b/tests/codegen/instrument-coverage-off.rs
new file mode 100644
index 00000000000..ca803beec0b
--- /dev/null
+++ b/tests/codegen/instrument-coverage-off.rs
@@ -0,0 +1,23 @@
+// Test that `-Cinstrument-coverage=off` does not add coverage instrumentation to LLVM IR.
+
+// needs-profiler-support
+// revisions: n no off false zero
+// [n] compile-flags: -Cinstrument-coverage=n
+// [no] compile-flags: -Cinstrument-coverage=no
+// [off] compile-flags: -Cinstrument-coverage=off
+// [false] compile-flags: -Cinstrument-coverage=false
+// [zero] compile-flags: -Cinstrument-coverage=0
+
+// CHECK-NOT: __llvm_profile_filename
+// CHECK-NOT: __llvm_coverage_mapping
+
+#![crate_type="lib"]
+
+#[inline(never)]
+fn some_function() {
+
+}
+
+pub fn some_other_function() {
+    some_function();
+}
diff --git a/tests/codegen/instrument-coverage.rs b/tests/codegen/instrument-coverage.rs
index 78f8875a2d9..f8437dac463 100644
--- a/tests/codegen/instrument-coverage.rs
+++ b/tests/codegen/instrument-coverage.rs
@@ -1,9 +1,16 @@
 // Test that `-Cinstrument-coverage` creates expected __llvm_profile_filename symbol in LLVM IR.
 
 // needs-profiler-support
-// compile-flags: -Cinstrument-coverage
+// revisions: default y yes on true all
+// [default] compile-flags: -Cinstrument-coverage
+// [y] compile-flags: -Cinstrument-coverage=y
+// [yes] compile-flags: -Cinstrument-coverage=yes
+// [on] compile-flags: -Cinstrument-coverage=on
+// [true] compile-flags: -Cinstrument-coverage=true
+// [all] compile-flags: -Cinstrument-coverage=all
 
 // CHECK: @__llvm_profile_filename = {{.*}}"default_%m_%p.profraw\00"{{.*}}
+// CHECK: @__llvm_coverage_mapping
 
 #![crate_type="lib"]
 
diff --git a/tests/codegen/instrument-mcount.rs b/tests/codegen/instrument-mcount.rs
index b26076e7a7b..50823775a41 100644
--- a/tests/codegen/instrument-mcount.rs
+++ b/tests/codegen/instrument-mcount.rs
@@ -1,5 +1,5 @@
 //
-// compile-flags: -Z instrument-mcount
+// compile-flags: -Z instrument-mcount -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/instrument-xray/basic.rs b/tests/codegen/instrument-xray/basic.rs
index d3e49d53174..5da878474f2 100644
--- a/tests/codegen/instrument-xray/basic.rs
+++ b/tests/codegen/instrument-xray/basic.rs
@@ -1,7 +1,7 @@
 // Checks that `-Z instrument-xray` produces expected instrumentation.
 //
 // needs-xray
-// compile-flags: -Z instrument-xray=always
+// compile-flags: -Z instrument-xray=always -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/instrument-xray/options-combine.rs b/tests/codegen/instrument-xray/options-combine.rs
index f7e500b65f6..d1e56586279 100644
--- a/tests/codegen/instrument-xray/options-combine.rs
+++ b/tests/codegen/instrument-xray/options-combine.rs
@@ -1,9 +1,9 @@
 // Checks that `-Z instrument-xray` options can be specified multiple times.
 //
 // needs-xray
-// compile-flags: -Z instrument-xray=skip-exit
-// compile-flags: -Z instrument-xray=instruction-threshold=123
-// compile-flags: -Z instrument-xray=instruction-threshold=456
+// compile-flags: -Z instrument-xray=skip-exit -Copt-level=0
+// compile-flags: -Z instrument-xray=instruction-threshold=123 -Copt-level=0
+// compile-flags: -Z instrument-xray=instruction-threshold=456 -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/instrument-xray/options-override.rs b/tests/codegen/instrument-xray/options-override.rs
index 00f81837902..b1fc4c966dc 100644
--- a/tests/codegen/instrument-xray/options-override.rs
+++ b/tests/codegen/instrument-xray/options-override.rs
@@ -1,8 +1,8 @@
 // Checks that the last `-Z instrument-xray` option wins.
 //
 // needs-xray
-// compile-flags: -Z instrument-xray=always
-// compile-flags: -Z instrument-xray=never
+// compile-flags: -Z instrument-xray=always -Copt-level=0
+// compile-flags: -Z instrument-xray=never -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/issue-97217.rs b/tests/codegen/issue-97217.rs
new file mode 100644
index 00000000000..af7345442fc
--- /dev/null
+++ b/tests/codegen/issue-97217.rs
@@ -0,0 +1,22 @@
+// compile-flags: -C opt-level=3
+// ignore-debug: the debug assertions get in the way
+// min-llvm-version: 17.0.2
+#![crate_type = "lib"]
+
+// Regression test for issue 97217 (the following should result in no allocations)
+
+// CHECK-LABEL: @issue97217
+#[no_mangle]
+pub fn issue97217() -> i32 {
+    // drop_in_place should be inlined and never appear
+    // CHECK-NOT: drop_in_place
+
+    // __rust_alloc should be optimized out
+    // CHECK-NOT: __rust_alloc
+
+    let v1 = vec![5, 6, 7];
+    let v1_iter = v1.iter();
+    let total: i32 = v1_iter.sum();
+    println!("{}",total);
+    total
+}
diff --git a/tests/codegen/panic-unwind-default-uwtable.rs b/tests/codegen/panic-unwind-default-uwtable.rs
index 4c85008cf35..b78b159d20d 100644
--- a/tests/codegen/panic-unwind-default-uwtable.rs
+++ b/tests/codegen/panic-unwind-default-uwtable.rs
@@ -1,4 +1,4 @@
-// compile-flags: -C panic=unwind -C no-prepopulate-passes
+// compile-flags: -C panic=unwind -C no-prepopulate-passes -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs
index 47243bece98..b39718a8d08 100644
--- a/tests/codegen/personality_lifetimes.rs
+++ b/tests/codegen/personality_lifetimes.rs
@@ -9,10 +9,12 @@
 struct S;
 
 impl Drop for S {
+    #[inline(never)]
     fn drop(&mut self) {
     }
 }
 
+#[inline(never)]
 fn might_unwind() {
 }
 
diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs
index 084d8bf803c..f16890afad0 100644
--- a/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs
+++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs
@@ -1,7 +1,7 @@
 // Verifies that user-defined CFI encoding for types are emitted.
 //
 // needs-sanitizer-cfi
-// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
+// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
 
 #![crate_type="lib"]
 #![feature(cfi_encoding, extern_types)]
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 2d8b13e2080..4ed7c27fc4e 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
@@ -1,7 +1,7 @@
 // Verifies that type metadata identifiers for functions are emitted correctly.
 //
 // needs-sanitizer-cfi
-// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
+// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
 
 #![crate_type="lib"]
 #![allow(dead_code)]
diff --git a/tests/codegen/sanitizer/cfi-generalize-pointers.rs b/tests/codegen/sanitizer/cfi-generalize-pointers.rs
index 677ebdb27ec..17cb42d3e74 100644
--- a/tests/codegen/sanitizer/cfi-generalize-pointers.rs
+++ b/tests/codegen/sanitizer/cfi-generalize-pointers.rs
@@ -1,7 +1,7 @@
 // Verifies that pointer types are generalized.
 //
 // needs-sanitizer-cfi
-// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
+// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0
 
 #![crate_type="lib"]
 
diff --git a/tests/codegen/sanitizer/cfi-normalize-integers.rs b/tests/codegen/sanitizer/cfi-normalize-integers.rs
index aa3913cb8e7..9663aa54c28 100644
--- a/tests/codegen/sanitizer/cfi-normalize-integers.rs
+++ b/tests/codegen/sanitizer/cfi-normalize-integers.rs
@@ -1,7 +1,7 @@
 // Verifies that integer types are normalized.
 //
 // needs-sanitizer-cfi
-// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
+// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0
 
 #![crate_type="lib"]
 
diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs
index 783bc47b9d0..29d50d8df24 100644
--- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs
+++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs
@@ -1,6 +1,6 @@
 // Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation.
 
-// compile-flags: -Zsanitizer=kernel-address
+// compile-flags: -Zsanitizer=kernel-address -Copt-level=0
 // revisions: aarch64 riscv64imac riscv64gc x86_64
 //[aarch64] compile-flags: --target aarch64-unknown-none
 //[aarch64] needs-llvm-components: aarch64
diff --git a/tests/codegen/sanitizer/memtag-attr-check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs
index 2fd362656d4..3e5e14e8429 100644
--- a/tests/codegen/sanitizer/memtag-attr-check.rs
+++ b/tests/codegen/sanitizer/memtag-attr-check.rs
@@ -2,7 +2,7 @@
 // applied when enabling the memtag sanitizer.
 //
 // needs-sanitizer-memtag
-// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte
+// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs
index d0b69243453..029cf8e7f5c 100644
--- a/tests/codegen/sanitizer/no-sanitize.rs
+++ b/tests/codegen/sanitizer/no-sanitize.rs
@@ -2,7 +2,7 @@
 // selectively disable sanitizer instrumentation.
 //
 // needs-sanitizer-address
-// compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static
+// compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0
 
 #![crate_type="lib"]
 #![feature(no_sanitize)]
diff --git a/tests/codegen/sanitizer/safestack-attr-check.rs b/tests/codegen/sanitizer/safestack-attr-check.rs
index b73ed00e730..b19e2d13133 100644
--- a/tests/codegen/sanitizer/safestack-attr-check.rs
+++ b/tests/codegen/sanitizer/safestack-attr-check.rs
@@ -1,7 +1,7 @@
 // This tests that the safestack attribute is applied when enabling the safe-stack sanitizer.
 //
 // needs-sanitizer-safestack
-// compile-flags: -Zsanitizer=safestack
+// compile-flags: -Zsanitizer=safestack -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/simd/simd-wide-sum.rs b/tests/codegen/simd/simd-wide-sum.rs
index 3116f9597bc..6e7d3d9316a 100644
--- a/tests/codegen/simd/simd-wide-sum.rs
+++ b/tests/codegen/simd/simd-wide-sum.rs
@@ -11,14 +11,14 @@
 #![feature(portable_simd)]
 
 use std::simd::{Simd, SimdUint};
-const N: usize = 8;
+const N: usize = 16;
 
 #[no_mangle]
 // CHECK-LABEL: @wider_reduce_simd
 pub fn wider_reduce_simd(x: Simd<u8, N>) -> u16 {
-    // CHECK: zext <8 x i8>
-    // CHECK-SAME: to <8 x i16>
-    // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
+    // CHECK: zext <16 x i8>
+    // CHECK-SAME: to <16 x i16>
+    // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
     let x: Simd<u16, N> = x.cast();
     x.reduce_sum()
 }
@@ -26,9 +26,9 @@ pub fn wider_reduce_simd(x: Simd<u8, N>) -> u16 {
 #[no_mangle]
 // CHECK-LABEL: @wider_reduce_loop
 pub fn wider_reduce_loop(x: Simd<u8, N>) -> u16 {
-    // CHECK: zext <8 x i8>
-    // CHECK-SAME: to <8 x i16>
-    // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
+    // CHECK: zext <16 x i8>
+    // CHECK-SAME: to <16 x i16>
+    // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
     let mut sum = 0_u16;
     for i in 0..N {
         sum += u16::from(x[i]);
@@ -39,9 +39,9 @@ pub fn wider_reduce_loop(x: Simd<u8, N>) -> u16 {
 #[no_mangle]
 // CHECK-LABEL: @wider_reduce_iter
 pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
-    // CHECK: zext <8 x i8>
-    // CHECK-SAME: to <8 x i16>
-    // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
+    // CHECK: zext <16 x i8>
+    // CHECK-SAME: to <16 x i16>
+    // CHECK: call i16 @llvm.vector.reduce.add.v16i16(<16 x i16>
     x.as_array().iter().copied().map(u16::from).sum()
 }
 
@@ -52,8 +52,8 @@ pub fn wider_reduce_iter(x: Simd<u8, N>) -> u16 {
 #[no_mangle]
 // CHECK-LABEL: @wider_reduce_into_iter
 pub fn wider_reduce_into_iter(x: Simd<u8, N>) -> u16 {
-    // CHECK: zext <8 x i8>
-    // CHECK-SAME: to <8 x i16>
-    // CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16>
+    // FIXME: It would be nice if this was exactly the same as the above tests,
+    // but at the time of writing this comment, that didn't happen on LLVM main.
+    // CHECK: call i16 @llvm.vector.reduce.add
     x.to_array().into_iter().map(u16::from).sum()
 }
diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
index 64be1127786..6ef0f0406d2 100644
--- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
+++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
@@ -1,4 +1,4 @@
-// compile-flags: -g -Z src-hash-algorithm=md5
+// compile-flags: -g -Z src-hash-algorithm=md5 -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
index 54e07152142..ebfa3040aca 100644
--- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
+++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
@@ -1,4 +1,4 @@
-// compile-flags: -g -Z src-hash-algorithm=sha1
+// compile-flags: -g -Z src-hash-algorithm=sha1 -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
index dc7db8e2372..5ec678d55f3 100644
--- a/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
+++ b/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
@@ -1,4 +1,4 @@
-// compile-flags: -g -Z src-hash-algorithm=sha256
+// compile-flags: -g -Z src-hash-algorithm=sha256 -Copt-level=0
 
 #![crate_type = "lib"]
 
diff --git a/tests/codegen/target-cpu-on-functions.rs b/tests/codegen/target-cpu-on-functions.rs
index c043eceb5cd..d5250f22cca 100644
--- a/tests/codegen/target-cpu-on-functions.rs
+++ b/tests/codegen/target-cpu-on-functions.rs
@@ -15,7 +15,8 @@ pub extern "C" fn exported() {
 
 // CHECK-LABEL: ; target_cpu_on_functions::not_exported
 // CHECK-NEXT: ; Function Attrs:
-// CHECK-NEXT: define {{.*}}() {{.*}} #0
+// CHECK-NEXT: define {{.*}}() {{.*}} #1
+#[inline(never)]
 fn not_exported() {}
 
 // CHECK: attributes #0 = {{.*}} "target-cpu"="{{.*}}"
diff --git a/tests/codegen/target-feature-inline-closure.rs b/tests/codegen/target-feature-inline-closure.rs
index d075706173f..54cb27242d5 100644
--- a/tests/codegen/target-feature-inline-closure.rs
+++ b/tests/codegen/target-feature-inline-closure.rs
@@ -31,3 +31,7 @@ unsafe fn without_avx(x: __m256) -> __m256 {
     };
     add(x, x)
 }
+
+// Don't allow the above CHECK-NOT to accidentally match a commit hash in the
+// compiler version.
+// CHECK-LABEL: rustc version
diff --git a/tests/codegen/tied-features-strength.rs b/tests/codegen/tied-features-strength.rs
index 51334c12158..71cea48c4da 100644
--- a/tests/codegen/tied-features-strength.rs
+++ b/tests/codegen/tied-features-strength.rs
@@ -7,16 +7,16 @@
 // are targeting older LLVM versions. Once the min supported version
 // is LLVM-14 we can remove the optional regex matching for this feature.
 
-// [ENABLE_SVE] compile-flags: -C target-feature=+sve
+// [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0
 // ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?))*}}" }
 
-// [DISABLE_SVE] compile-flags: -C target-feature=-sve
+// [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0
 // DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" }
 
-// [DISABLE_NEON] compile-flags: -C target-feature=-neon
+// [DISABLE_NEON] compile-flags: -C target-feature=-neon -Copt-level=0
 // DISABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-fp-armv8,?)|(-neon,?))*}}" }
 
-// [ENABLE_NEON] compile-flags: -C target-feature=+neon
+// [ENABLE_NEON] compile-flags: -C target-feature=+neon -Copt-level=0
 // ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" }
 
 
diff --git a/tests/codegen/tune-cpu-on-functions.rs b/tests/codegen/tune-cpu-on-functions.rs
index ed8dc0e9383..116f0772d25 100644
--- a/tests/codegen/tune-cpu-on-functions.rs
+++ b/tests/codegen/tune-cpu-on-functions.rs
@@ -3,7 +3,7 @@
 
 // no-prefer-dynamic
 //
-// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic
+// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic -Copt-level=0
 
 #![crate_type = "staticlib"]
 
diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs
index d5f53bedd54..aca9bec77df 100644
--- a/tests/codegen/unchecked_shifts.rs
+++ b/tests/codegen/unchecked_shifts.rs
@@ -2,7 +2,7 @@
 // ignore-debug (because unchecked is checked in debug)
 
 #![crate_type = "lib"]
-#![feature(unchecked_math)]
+#![feature(unchecked_shifts)]
 
 // CHECK-LABEL: @unchecked_shl_unsigned_same
 #[no_mangle]
diff --git a/tests/codegen/unwind-landingpad-cold.rs b/tests/codegen/unwind-landingpad-cold.rs
new file mode 100644
index 00000000000..3a902a7d712
--- /dev/null
+++ b/tests/codegen/unwind-landingpad-cold.rs
@@ -0,0 +1,16 @@
+// compile-flags: -Cno-prepopulate-passes
+// needs-unwind
+// min-llvm-version: 17.0.2
+#![crate_type = "lib"]
+
+// This test checks that drop calls in unwind landing pads
+// get the `cold` attribute.
+
+// CHECK-LABEL: @check_cold
+// CHECK: {{(call|invoke) void .+}}drop_in_place{{.+}} [[ATTRIBUTES:#[0-9]+]]
+// CHECK: attributes [[ATTRIBUTES]] = { cold }
+#[no_mangle]
+pub fn check_cold(f: fn(), x: Box<u32>) {
+    // this may unwind
+    f();
+}
diff --git a/tests/codegen/unwind-landingpad-inline.rs b/tests/codegen/unwind-landingpad-inline.rs
new file mode 100644
index 00000000000..0774cefdd2d
--- /dev/null
+++ b/tests/codegen/unwind-landingpad-inline.rs
@@ -0,0 +1,39 @@
+// min-llvm-version: 17.0.2
+// compile-flags: -Copt-level=3
+// ignore-debug: the debug assertions get in the way
+#![crate_type = "lib"]
+
+// This test checks that we can inline drop_in_place in
+// unwind landing pads.
+
+// Without inlining, the box pointers escape via the call to drop_in_place,
+// and LLVM will not optimize out the pointer comparison.
+// With inlining, everything should be optimized out.
+// See https://github.com/rust-lang/rust/issues/46515
+// CHECK-LABEL: @check_no_escape_in_landingpad
+// CHECK: start:
+// CHECK-NEXT: __rust_no_alloc_shim_is_unstable
+// CHECK-NEXT: __rust_no_alloc_shim_is_unstable
+// CHECK-NEXT: ret void
+#[no_mangle]
+pub fn check_no_escape_in_landingpad(f: fn()) {
+    let x = &*Box::new(0);
+    let y = &*Box::new(0);
+
+    if x as *const _ == y as *const _ {
+        f();
+    }
+}
+
+// Without inlining, the compiler can't tell that
+// dropping an empty string (in a landing pad) does nothing.
+// With inlining, the landing pad should be optimized out.
+// See https://github.com/rust-lang/rust/issues/87055
+// CHECK-LABEL: @check_eliminate_noop_drop
+// CHECK: call void %g()
+// CHECK-NEXT: ret void
+#[no_mangle]
+pub fn check_eliminate_noop_drop(g: fn()) {
+    let _var = String::new();
+    g();
+}
diff --git a/tests/codegen/vec-reserve-extend.rs b/tests/codegen/vec-reserve-extend.rs
new file mode 100644
index 00000000000..d95220104c2
--- /dev/null
+++ b/tests/codegen/vec-reserve-extend.rs
@@ -0,0 +1,14 @@
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @should_reserve_once
+#[no_mangle]
+pub fn should_reserve_once(v: &mut Vec<u8>) {
+    // CHECK: tail call void @llvm.assume
+    v.try_reserve(3).unwrap();
+    // CHECK-NOT: call {{.*}}reserve
+    // CHECK-NOT: call {{.*}}do_reserve_and_handle
+    // CHECK-NOT: call {{.*}}__rust_alloc(
+    v.extend([1, 2, 3]);
+}
diff --git a/tests/codegen/vec_pop_push_noop.rs b/tests/codegen/vec_pop_push_noop.rs
new file mode 100644
index 00000000000..8bc7b68a816
--- /dev/null
+++ b/tests/codegen/vec_pop_push_noop.rs
@@ -0,0 +1,24 @@
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+#[no_mangle]
+// CHECK-LABEL: @noop(
+pub fn noop(v: &mut Vec<u8>) {
+    // CHECK-NOT: reserve_for_push
+    // CHECK-NOT: call
+    // CHECK: tail call void @llvm.assume
+    // CHECK-NOT: reserve_for_push
+    // CHECK-NOT: call
+    // CHECK: ret
+    if let Some(x) = v.pop() {
+        v.push(x)
+    }
+}
+
+#[no_mangle]
+// CHECK-LABEL: @push_byte(
+pub fn push_byte(v: &mut Vec<u8>) {
+    // CHECK: call {{.*}}reserve_for_push
+    v.push(3);
+}