about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2025-06-30 17:42:03 +0300
committerLaurențiu Nicola <lnicola@dend.ro>2025-06-30 17:42:03 +0300
commit0edf5726c773484b53f9612f687dec916a60883f (patch)
tree69ecc9ed7f6fb830c4814d1085ba96820b4ab864 /tests/codegen
parent3b5b35052ca29244f6681a995d8b372b39f210b4 (diff)
parentad3b7257615c28aaf8212a189ec032b8af75de51 (diff)
downloadrust-0edf5726c773484b53f9612f687dec916a60883f.tar.gz
rust-0edf5726c773484b53f9612f687dec916a60883f.zip
Merge from rust-lang/rust
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/abi-x86-interrupt.rs6
-rw-r--r--tests/codegen/min-function-alignment.rs10
-rw-r--r--tests/codegen/transmute-scalar.rs45
3 files changed, 53 insertions, 8 deletions
diff --git a/tests/codegen/abi-x86-interrupt.rs b/tests/codegen/abi-x86-interrupt.rs
index 255ccba2c11..9a1ded2c9e3 100644
--- a/tests/codegen/abi-x86-interrupt.rs
+++ b/tests/codegen/abi-x86-interrupt.rs
@@ -13,8 +13,6 @@
 extern crate minicore;
 use minicore::*;
 
-// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
+// CHECK: define x86_intrcc void @has_x86_interrupt_abi
 #[no_mangle]
-pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 {
-    a
-}
+pub extern "x86-interrupt" fn has_x86_interrupt_abi() {}
diff --git a/tests/codegen/min-function-alignment.rs b/tests/codegen/min-function-alignment.rs
index 75f845572a4..78989ec5df2 100644
--- a/tests/codegen/min-function-alignment.rs
+++ b/tests/codegen/min-function-alignment.rs
@@ -1,17 +1,19 @@
 //@ revisions: align16 align1024
-//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0
+//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code
 //@ [align16] compile-flags: -Zmin-function-alignment=16
 //@ [align1024] compile-flags: -Zmin-function-alignment=1024
 
 #![crate_type = "lib"]
 #![feature(fn_align)]
 
-// functions without explicit alignment use the global minimum
+// Functions without explicit alignment use the global minimum.
 //
-// CHECK-LABEL: @no_explicit_align
+// NOTE: this function deliberately has zero (0) attributes! That is to make sure that
+// `-Zmin-function-alignment` is applied regardless of whether attributes are used.
+//
+// CHECK-LABEL: no_explicit_align
 // align16: align 16
 // align1024: align 1024
-#[no_mangle]
 pub fn no_explicit_align() {}
 
 // CHECK-LABEL: @lower_align
diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs
index c080259a917..c57ade58c30 100644
--- a/tests/codegen/transmute-scalar.rs
+++ b/tests/codegen/transmute-scalar.rs
@@ -55,3 +55,48 @@ pub fn ptr_to_int(p: *mut u16) -> usize {
 pub fn int_to_ptr(i: usize) -> *mut u16 {
     unsafe { std::mem::transmute(i) }
 }
+
+// This is the one case where signedness matters to transmuting:
+// the LLVM type is `i8` here because of `repr(i8)`,
+// whereas below with the `repr(u8)` it's `i1` in LLVM instead.
+#[repr(i8)]
+pub enum FakeBoolSigned {
+    False = 0,
+    True = 1,
+}
+
+// CHECK-LABEL: define{{.*}}i8 @bool_to_fake_bool_signed(i1 zeroext %b)
+// CHECK: %_0 = zext i1 %b to i8
+// CHECK-NEXT: ret i8 %_0
+#[no_mangle]
+pub fn bool_to_fake_bool_signed(b: bool) -> FakeBoolSigned {
+    unsafe { std::mem::transmute(b) }
+}
+
+// CHECK-LABEL: define{{.*}}i1 @fake_bool_signed_to_bool(i8 %b)
+// CHECK: %_0 = trunc nuw i8 %b to i1
+// CHECK-NEXT: ret i1 %_0
+#[no_mangle]
+pub fn fake_bool_signed_to_bool(b: FakeBoolSigned) -> bool {
+    unsafe { std::mem::transmute(b) }
+}
+
+#[repr(u8)]
+pub enum FakeBoolUnsigned {
+    False = 0,
+    True = 1,
+}
+
+// CHECK-LABEL: define{{.*}}i1 @bool_to_fake_bool_unsigned(i1 zeroext %b)
+// CHECK: ret i1 %b
+#[no_mangle]
+pub fn bool_to_fake_bool_unsigned(b: bool) -> FakeBoolUnsigned {
+    unsafe { std::mem::transmute(b) }
+}
+
+// CHECK-LABEL: define{{.*}}i1 @fake_bool_unsigned_to_bool(i1 zeroext %b)
+// CHECK: ret i1 %b
+#[no_mangle]
+pub fn fake_bool_unsigned_to_bool(b: FakeBoolUnsigned) -> bool {
+    unsafe { std::mem::transmute(b) }
+}