|
| 1 | +// Test for -Z small_data_threshold=... |
| 2 | +// revisions: RISCV MIPS HEXAGON M68K |
| 3 | +// assembly-output: emit-asm |
| 4 | +// compile-flags: -Z small_data_threshold=4 |
| 5 | +// [RISCV] compile-flags:--target=riscv32im-unknown-none-elf |
| 6 | +// [MIPS] compile-flags:--target=mips-unknown-linux-musl -C llvm-args=-relocation-model=static -C llvm-args=-membedded-data -C llvm-args=-mgpopt -C llvm-args=-target-abi=n64 |
| 7 | +// [HEXAGON] compile-flags:--target=hexagon-unknown-linux-musl -C target-feature=+small-data -C llvm-args=--hexagon-statics-in-small-data |
| 8 | +// [M68K] compile-flags:--target=m68k-unknown-linux-gnu |
| 9 | + |
| 10 | +#![feature(no_core, lang_items)] |
| 11 | +#![no_std] |
| 12 | +#![no_core] |
| 13 | +#![crate_type = "lib"] |
| 14 | + |
| 15 | +#[lang = "sized"] |
| 16 | +trait Sized {} |
| 17 | + |
| 18 | +#[lang = "drop_in_place"] |
| 19 | +fn drop_in_place<T>(_: *mut T) {} |
| 20 | + |
| 21 | +#[used] |
| 22 | +#[no_mangle] |
| 23 | +// U is below the threshold, should be in sdata |
| 24 | +pub static mut U: u16 = 123; |
| 25 | + |
| 26 | +#[used] |
| 27 | +#[no_mangle] |
| 28 | +// V is below the threshold, should be in sbss |
| 29 | +pub static mut V: u16 = 0; |
| 30 | + |
| 31 | +#[used] |
| 32 | +#[no_mangle] |
| 33 | +// W is at the threshold, should be in sdata |
| 34 | +pub static mut W: u32 = 123; |
| 35 | + |
| 36 | +#[used] |
| 37 | +#[no_mangle] |
| 38 | +// X is at the threshold, should be in sbss |
| 39 | +pub static mut X: u32 = 0; |
| 40 | + |
| 41 | +#[used] |
| 42 | +#[no_mangle] |
| 43 | +// Y is over the threshold, should be in its own .data section |
| 44 | +pub static mut Y: u64 = 123; |
| 45 | + |
| 46 | +#[used] |
| 47 | +#[no_mangle] |
| 48 | +/// Z is over the threshold, should be in its own .bss section |
| 49 | +pub static mut Z: u64 = 0; |
| 50 | + |
| 51 | +// Currently, only RISCV successfully puts any objects in the small data |
| 52 | +// sections so the U/V/W/X tests are skipped on MIPS/Hexagon/M68K |
| 53 | +// RISCV: .section .sdata, |
| 54 | +// RISCV-NOT: .section |
| 55 | +// RISCV: U: |
| 56 | +// RISCV: .section .sbss |
| 57 | +// RISV-NOT: .section |
| 58 | +// RISCV: V: |
| 59 | +// RISCV .section .sdata |
| 60 | +// RISV-NOT: .section |
| 61 | +// RISCV: W: |
| 62 | +// RISCV: .section .sbss |
| 63 | +// RISV-NOT: .section |
| 64 | +// RISCV: X: |
| 65 | +// CHECK: .section .data.Y, |
| 66 | +// CHECK-NOT: .section |
| 67 | +// CHECK: Y: |
| 68 | +// CHECK: .section .bss.Z, |
| 69 | +// CHECK-NOT: .section |
| 70 | +// CHECK: Z: |
0 commit comments