]> git.lizzy.rs Git - rust.git/commitdiff
Update codegen tests to accommodate the potential presence/absence of the
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 19 Aug 2022 20:15:15 +0000 (16:15 -0400)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 19 Aug 2022 20:15:15 +0000 (16:15 -0400)
extension operation depending on target architecture.

src/test/codegen/abi-repr-ext.rs
src/test/codegen/pic-relocation-model.rs

index 2b34eaf94172be8536b94eb3897365b3d271d324..23ade3c7216d3c46070fbc49556281bbdbfbab02 100644 (file)
@@ -1,6 +1,32 @@
 // compile-flags: -O
 
-#![crate_type="lib"]
+// revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv
+
+//[x86_64] compile-flags: --target x86_64-unknown-uefi
+//[x86_64] needs-llvm-components: x86
+//[i686] compile-flags: --target i686-unknown-linux-musl
+//[i686] needs-llvm-components: x86
+//[aarch64-windows] compile-flags: --target aarch64-pc-windows-msvc
+//[aarch64-windows] needs-llvm-components: aarch64
+//[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu
+//[aarch64-linux] needs-llvm-components: aarch64
+//[aarch64-apple] compile-flags: --target aarch64-apple-darwin
+//[aarch64-apple] needs-llvm-components: aarch64
+//[arm] compile-flags: --target armv7r-none-eabi
+//[arm] needs-llvm-components: arm
+//[riscv] compile-flags: --target riscv64gc-unknown-none-elf
+//[riscv] needs-llvm-components: riscv
+
+// See bottom of file for a corresponding C source file that is meant to yield
+// equivalent declarations.
+#![feature(no_core, lang_items)]
+#![crate_type = "lib"]
+#![no_std]
+#![no_core]
+
+#[lang="sized"] trait Sized { }
+#[lang="freeze"] trait Freeze { }
+#[lang="copy"] trait Copy { }
 
 #[repr(i8)]
 pub enum Type {
@@ -8,7 +34,23 @@ pub enum Type {
     Type2 = 1
 }
 
-// CHECK: define{{( dso_local)?}} noundef signext i8 @test()
+// To accommodate rust#97800, one might consider writing the below as:
+//
+// `define{{( dso_local)?}} noundef{{( signext)?}} i8 @test()`
+//
+// but based on rust#80556, it seems important to actually check for the
+// presence of the `signext` for those targets where we expect it.
+
+// CHECK: define{{( dso_local)?}} noundef
+// x86_64-SAME:                 signext
+// aarch64-apple-SAME:          signext
+// aarch64-windows-NOT: signext
+// aarch64-linux-NOT:   signext
+// arm-SAME:                    signext
+// riscv-SAME:                  signext
+// CHECK-SAME: i8 @test()
+
+
 #[no_mangle]
 pub extern "C" fn test() -> Type {
     Type::Type1
index 6e1d5a6c3f2712f22fca6991cd44ca62ea8f8fce..9b378ecb4e590651cc7b8b8a41a11c957160fcd1 100644 (file)
@@ -10,7 +10,10 @@ pub fn call_foreign_fn() -> u8 {
     }
 }
 
-// CHECK: declare zeroext i8 @foreign_fn()
+// (Allow but do not require `zeroext` here, because it is not worth effort to
+// spell out which targets have it and which ones do not; see rust#97800.)
+
+// CHECK: declare{{( zeroext)?}} i8 @foreign_fn()
 extern "C" {fn foreign_fn() -> u8;}
 
 // CHECK: !{i32 7, !"PIC Level", i32 2}