2021-05-25 21:54:07 +00:00
|
|
|
// revisions: x64 A64 ppc64le
|
2021-03-27 22:11:24 +00:00
|
|
|
// assembly-output: emit-asm
|
2021-05-13 23:56:00 +00:00
|
|
|
// [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static
|
2021-06-13 18:19:39 +00:00
|
|
|
// [x64] needs-llvm-components: x86
|
2021-03-27 22:11:24 +00:00
|
|
|
// [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static
|
2021-06-13 18:19:39 +00:00
|
|
|
// [A64] needs-llvm-components: aarch64
|
2021-05-25 21:54:07 +00:00
|
|
|
// [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static
|
2021-06-13 18:19:39 +00:00
|
|
|
// [ppc64le] needs-llvm-components: powerpc
|
2021-03-27 22:11:24 +00:00
|
|
|
|
|
|
|
#![feature(no_core, lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
#[lang="sized"]
|
|
|
|
trait Sized {}
|
|
|
|
|
|
|
|
#[lang="copy"]
|
|
|
|
trait Copy {}
|
|
|
|
|
2021-05-14 01:47:41 +00:00
|
|
|
#[lang="sync"]
|
|
|
|
trait Sync {}
|
|
|
|
|
|
|
|
#[lang = "drop_in_place"]
|
|
|
|
fn drop_in_place<T>(_: *mut T) {}
|
|
|
|
|
2021-03-27 22:11:24 +00:00
|
|
|
impl Copy for u8 {}
|
2021-05-14 01:47:41 +00:00
|
|
|
impl Sync for u8 {}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub static PIERIS: u8 = 42;
|
2021-03-27 22:11:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
2021-05-14 01:47:41 +00:00
|
|
|
static EXOCHORDA: *mut u8;
|
|
|
|
|
2021-03-27 22:11:24 +00:00
|
|
|
fn chaenomeles();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: banana:
|
2022-07-20 12:56:42 +00:00
|
|
|
// On the next line LLVM 14 produces a `movb`, whereas LLVM 15+ produces a `movzbl`.
|
|
|
|
// x64: {{movb|movzbl}} chaenomeles{{(\(%[a-z0-9]+\))?}}, %{{[a-z0-9]+}}
|
2021-03-27 22:11:24 +00:00
|
|
|
// A64: adrp [[REG:[a-z0-9]+]], chaenomeles
|
|
|
|
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn banana() -> u8 {
|
|
|
|
unsafe {
|
|
|
|
*(chaenomeles as *mut u8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: peach:
|
2022-07-20 12:56:42 +00:00
|
|
|
// x64: {{movb|movzbl}} banana{{(\(%[a-z0-9]+\))?}}, %{{[a-z0-9]+}}
|
2021-03-27 22:11:24 +00:00
|
|
|
// A64: adrp [[REG2:[a-z0-9]+]], banana
|
|
|
|
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn peach() -> u8 {
|
|
|
|
unsafe {
|
|
|
|
*(banana as *mut u8)
|
|
|
|
}
|
|
|
|
}
|
2021-05-14 01:47:41 +00:00
|
|
|
|
|
|
|
// CHECK-LABEL: mango:
|
|
|
|
// x64: movq EXOCHORDA{{(\(%[a-z0-9]+\))?}}, %[[REG:[a-z0-9]+]]
|
2022-07-20 12:56:42 +00:00
|
|
|
// x64-NEXT: {{movb|movzbl}} (%[[REG]]), %{{[a-z0-9]+}}
|
2021-05-14 01:47:41 +00:00
|
|
|
// A64: adrp [[REG2:[a-z0-9]+]], EXOCHORDA
|
|
|
|
// A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn mango() -> u8 {
|
|
|
|
unsafe {
|
|
|
|
*EXOCHORDA
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: orange:
|
|
|
|
// x64: mov{{l|absq}} $PIERIS, %{{[a-z0-9]+}}
|
|
|
|
// A64: adrp [[REG2:[a-z0-9]+]], PIERIS
|
|
|
|
// A64-NEXT: add {{[a-z0-9]+}}, [[REG2]], :lo12:PIERIS
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn orange() -> &'static u8 {
|
|
|
|
&PIERIS
|
|
|
|
}
|
2021-05-25 21:54:07 +00:00
|
|
|
|
|
|
|
// For ppc64 we need to make sure to generate TOC entries even with the static relocation model
|
|
|
|
// ppc64le: .tc chaenomeles[TC],chaenomeles
|
|
|
|
// ppc64le: .tc banana[TC],banana
|
|
|
|
// ppc64le: .tc EXOCHORDA[TC],EXOCHORDA
|
|
|
|
// ppc64le: .tc PIERIS[TC],PIERIS
|