Skip to content

Commit

Permalink
Update codegen tests to accommodate the potential presence/absence of…
Browse files Browse the repository at this point in the history
… the

extension operation depending on target architecture.
  • Loading branch information
pnkfelix committed Aug 19, 2022
1 parent 9bf3d5a commit 59cc718
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
46 changes: 44 additions & 2 deletions src/test/codegen/abi-repr-ext.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,56 @@
// 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 {
Type1 = 0,
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
Expand Down
5 changes: 4 additions & 1 deletion src/test/codegen/pic-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 59cc718

Please sign in to comment.