|
| 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 | +// [RISCV] needs-llvm-components: riscv |
| 7 | +// [MIPS] compile-flags: --target=mips-unknown-linux-uclibc -C relocation-model=static |
| 8 | +// [MIPS] compile-flags: -C llvm-args=-mgpopt -C llvm-args=-mlocal-sdata |
| 9 | +// [MIPS] compile-flags: -C target-feature=+noabicalls |
| 10 | +// [MIPS] needs-llvm-components: mips |
| 11 | +// [HEXAGON] compile-flags: --target=hexagon-unknown-linux-musl -C target-feature=+small-data |
| 12 | +// [HEXAGON] compile-flags: -C llvm-args=--hexagon-statics-in-small-data |
| 13 | +// [HEXAGON] needs-llvm-components: hexagon |
| 14 | +// [M68K] compile-flags: --target=m68k-unknown-linux-gnu |
| 15 | +// [M68K] needs-llvm-components: m68k |
| 16 | + |
| 17 | +#![feature(no_core, lang_items)] |
| 18 | +#![no_std] |
| 19 | +#![no_core] |
| 20 | +#![crate_type = "lib"] |
| 21 | + |
| 22 | +#[lang = "sized"] |
| 23 | +trait Sized {} |
| 24 | + |
| 25 | +#[lang = "drop_in_place"] |
| 26 | +fn drop_in_place<T>(_: *mut T) {} |
| 27 | + |
| 28 | +#[used] |
| 29 | +#[no_mangle] |
| 30 | +// U is below the threshold, should be in sdata |
| 31 | +static mut U: u16 = 123; |
| 32 | + |
| 33 | +#[used] |
| 34 | +#[no_mangle] |
| 35 | +// V is below the threshold, should be in sbss |
| 36 | +static mut V: u16 = 0; |
| 37 | + |
| 38 | +#[used] |
| 39 | +#[no_mangle] |
| 40 | +// W is at the threshold, should be in sdata |
| 41 | +static mut W: u32 = 123; |
| 42 | + |
| 43 | +#[used] |
| 44 | +#[no_mangle] |
| 45 | +// X is at the threshold, should be in sbss |
| 46 | +static mut X: u32 = 0; |
| 47 | + |
| 48 | +#[used] |
| 49 | +#[no_mangle] |
| 50 | +// Y is over the threshold, should be in its own .data section |
| 51 | +static mut Y: u64 = 123; |
| 52 | + |
| 53 | +#[used] |
| 54 | +#[no_mangle] |
| 55 | +/// Z is over the threshold, should be in its own .bss section |
| 56 | +static mut Z: u64 = 0; |
| 57 | + |
| 58 | +// Currently, only MIPS and RISCV successfully put any objects in the small data |
| 59 | +// sections so the U/V/W/X tests are skipped on Hexagon and M68K |
| 60 | + |
| 61 | +// RISCV: .section .sdata, |
| 62 | +// RISCV-NOT: .section |
| 63 | +// RISCV: U: |
| 64 | +// RISCV: .section .sbss |
| 65 | +// RISV-NOT: .section |
| 66 | +// RISCV: V: |
| 67 | +// RISCV .section .sdata |
| 68 | +// RISV-NOT: .section |
| 69 | +// RISCV: W: |
| 70 | +// RISCV: .section .sbss |
| 71 | +// RISV-NOT: .section |
| 72 | +// RISCV: X: |
| 73 | + |
| 74 | +// MIPS: .section .sdata, |
| 75 | +// MIPS-NOT: .section |
| 76 | +// MIPS: U: |
| 77 | +// MIPS: .section .sbss |
| 78 | +// RISV-NOT: .section |
| 79 | +// MIPS: V: |
| 80 | +// MIPS .section .sdata |
| 81 | +// RISV-NOT: .section |
| 82 | +// MIPS: W: |
| 83 | +// MIPS: .section .sbss |
| 84 | +// RISV-NOT: .section |
| 85 | +// MIPS: X: |
| 86 | + |
| 87 | +// CHECK: .section .data.Y, |
| 88 | +// CHECK-NOT: .section |
| 89 | +// CHECK: Y: |
| 90 | +// CHECK: .section .bss.Z, |
| 91 | +// CHECK-NOT: .section |
| 92 | +// CHECK: Z: |
0 commit comments