|
| 1 | +// Test for -Z large_data_threshold=... |
| 2 | +// This test verifies that with the medium code model, data above the threshold |
| 3 | +// is placed in large data sections (.ldata, .lbss, .lrodata). |
| 4 | +//@ assembly-output: emit-asm |
| 5 | +//@ compile-flags: -Ccode-model=medium -Zlarge-data-threshold=4 |
| 6 | +//@ compile-flags: --target=x86_64-unknown-linux-gnu |
| 7 | +//@ needs-llvm-components: x86 |
| 8 | + |
| 9 | +#![feature(no_core, lang_items)] |
| 10 | +#![no_std] |
| 11 | +#![no_core] |
| 12 | +#![crate_type = "lib"] |
| 13 | + |
| 14 | +#[lang = "pointee_sized"] |
| 15 | +pub trait PointeeSized {} |
| 16 | + |
| 17 | +#[lang = "meta_sized"] |
| 18 | +pub trait MetaSized: PointeeSized {} |
| 19 | + |
| 20 | +#[lang = "sized"] |
| 21 | +pub trait Sized: MetaSized {} |
| 22 | + |
| 23 | +#[lang = "drop_in_place"] |
| 24 | +fn drop_in_place<T>(_: *mut T) {} |
| 25 | + |
| 26 | +#[used] |
| 27 | +#[no_mangle] |
| 28 | +// U is below the threshold, should be in .data |
| 29 | +static mut U: u16 = 123; |
| 30 | + |
| 31 | +#[used] |
| 32 | +#[no_mangle] |
| 33 | +// V is below the threshold, should be in .bss |
| 34 | +static mut V: u16 = 0; |
| 35 | + |
| 36 | +#[used] |
| 37 | +#[no_mangle] |
| 38 | +// W is at the threshold, should be in .data |
| 39 | +static mut W: u32 = 123; |
| 40 | + |
| 41 | +#[used] |
| 42 | +#[no_mangle] |
| 43 | +// X is at the threshold, should be in .bss |
| 44 | +static mut X: u32 = 0; |
| 45 | + |
| 46 | +#[used] |
| 47 | +#[no_mangle] |
| 48 | +// Y is over the threshold, should be in .ldata |
| 49 | +static mut Y: u64 = 123; |
| 50 | + |
| 51 | +#[used] |
| 52 | +#[no_mangle] |
| 53 | +// Z is over the threshold, should be in .lbss |
| 54 | +static mut Z: u64 = 0; |
| 55 | + |
| 56 | +// CHECK: .section .data.U, |
| 57 | +// CHECK-NOT: .section |
| 58 | +// CHECK: U: |
| 59 | +// CHECK: .section .bss.V, |
| 60 | +// CHECK-NOT: .section |
| 61 | +// CHECK: V: |
| 62 | +// CHECK: .section .data.W, |
| 63 | +// CHECK-NOT: .section |
| 64 | +// CHECK: W: |
| 65 | +// CHECK: .section .bss.X, |
| 66 | +// CHECK-NOT: .section |
| 67 | +// CHECK: X: |
| 68 | +// CHECK: .section .ldata.Y, |
| 69 | +// CHECK-NOT: .section |
| 70 | +// CHECK: Y: |
| 71 | +// CHECK: .section .lbss.Z, |
| 72 | +// CHECK-NOT: .section |
| 73 | +// CHECK: Z: |
0 commit comments