This flag allows specifying the threshold size for placing static data in large data sections when using the medium code model on x86-64. When using -Ccode-model=medium, data smaller than this threshold uses RIP-relative addressing (32-bit offsets), while larger data uses absolute 64-bit addressing. This allows the compiler to generate more efficient code for smaller data while still supporting data larger than 2GB. This mirrors the -mlarge-data-threshold flag available in GCC and Clang. The default threshold is 65536 bytes (64KB) if not specified, matching LLVM's default behavior.
73 lines
1.6 KiB
Rust
73 lines
1.6 KiB
Rust
// Test for -Z large_data_threshold=...
|
|
// This test verifies that with the medium code model, data above the threshold
|
|
// is placed in large data sections (.ldata, .lbss, .lrodata).
|
|
//@ assembly-output: emit-asm
|
|
//@ compile-flags: -Ccode-model=medium -Zlarge-data-threshold=4
|
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu
|
|
//@ needs-llvm-components: x86
|
|
|
|
#![feature(no_core, lang_items)]
|
|
#![no_std]
|
|
#![no_core]
|
|
#![crate_type = "lib"]
|
|
|
|
#[lang = "pointee_sized"]
|
|
pub trait PointeeSized {}
|
|
|
|
#[lang = "meta_sized"]
|
|
pub trait MetaSized: PointeeSized {}
|
|
|
|
#[lang = "sized"]
|
|
pub trait Sized: MetaSized {}
|
|
|
|
#[lang = "drop_in_place"]
|
|
fn drop_in_place<T>(_: *mut T) {}
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// U is below the threshold, should be in .data
|
|
static mut U: u16 = 123;
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// V is below the threshold, should be in .bss
|
|
static mut V: u16 = 0;
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// W is at the threshold, should be in .data
|
|
static mut W: u32 = 123;
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// X is at the threshold, should be in .bss
|
|
static mut X: u32 = 0;
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// Y is over the threshold, should be in .ldata
|
|
static mut Y: u64 = 123;
|
|
|
|
#[used]
|
|
#[no_mangle]
|
|
// Z is over the threshold, should be in .lbss
|
|
static mut Z: u64 = 0;
|
|
|
|
// CHECK: .section .data.U,
|
|
// CHECK-NOT: .section
|
|
// CHECK: U:
|
|
// CHECK: .section .bss.V,
|
|
// CHECK-NOT: .section
|
|
// CHECK: V:
|
|
// CHECK: .section .data.W,
|
|
// CHECK-NOT: .section
|
|
// CHECK: W:
|
|
// CHECK: .section .bss.X,
|
|
// CHECK-NOT: .section
|
|
// CHECK: X:
|
|
// CHECK: .section .ldata.Y,
|
|
// CHECK-NOT: .section
|
|
// CHECK: Y:
|
|
// CHECK: .section .lbss.Z,
|
|
// CHECK-NOT: .section
|
|
// CHECK: Z:
|