mirror of
https://github.com/rust-lang/rust.git
synced 2026-03-19 20:27:30 +00:00
add -Zmin-function-alignment
This commit is contained in:
43
tests/codegen/min-function-alignment.rs
Normal file
43
tests/codegen/min-function-alignment.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
//@ revisions: align16 align1024
|
||||
//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0
|
||||
//@ [align16] compile-flags: -Zmin-function-alignment=16
|
||||
//@ [align1024] compile-flags: -Zmin-function-alignment=1024
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(fn_align)]
|
||||
|
||||
// functions without explicit alignment use the global minimum
|
||||
//
|
||||
// CHECK-LABEL: @no_explicit_align
|
||||
// align16: align 16
|
||||
// align1024: align 1024
|
||||
#[no_mangle]
|
||||
pub fn no_explicit_align() {}
|
||||
|
||||
// CHECK-LABEL: @lower_align
|
||||
// align16: align 16
|
||||
// align1024: align 1024
|
||||
#[no_mangle]
|
||||
#[repr(align(8))]
|
||||
pub fn lower_align() {}
|
||||
|
||||
// the higher value of min-function-alignment and repr(align) wins out
|
||||
//
|
||||
// CHECK-LABEL: @higher_align
|
||||
// align16: align 32
|
||||
// align1024: align 1024
|
||||
#[no_mangle]
|
||||
#[repr(align(32))]
|
||||
pub fn higher_align() {}
|
||||
|
||||
// cold functions follow the same rules as other functions
|
||||
//
|
||||
// in GCC, the `-falign-functions` does not apply to cold functions, but
|
||||
// `-Zmin-function-alignment` applies to all functions.
|
||||
//
|
||||
// CHECK-LABEL: @no_explicit_align_cold
|
||||
// align16: align 16
|
||||
// align1024: align 1024
|
||||
#[no_mangle]
|
||||
#[cold]
|
||||
pub fn no_explicit_align_cold() {}
|
||||
44
tests/codegen/naked-fn/min-function-alignment.rs
Normal file
44
tests/codegen/naked-fn/min-function-alignment.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes -Copt-level=0 -Zmin-function-alignment=16
|
||||
//@ needs-asm-support
|
||||
//@ ignore-arm no "ret" mnemonic
|
||||
|
||||
#![feature(naked_functions, fn_align)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// functions without explicit alignment use the global minimum
|
||||
//
|
||||
// CHECK: .balign 16
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
pub unsafe extern "C" fn naked_no_explicit_align() {
|
||||
core::arch::naked_asm!("ret")
|
||||
}
|
||||
|
||||
// CHECK: .balign 16
|
||||
#[no_mangle]
|
||||
#[repr(align(8))]
|
||||
#[naked]
|
||||
pub unsafe extern "C" fn naked_lower_align() {
|
||||
core::arch::naked_asm!("ret")
|
||||
}
|
||||
|
||||
// CHECK: .balign 32
|
||||
#[no_mangle]
|
||||
#[repr(align(32))]
|
||||
#[naked]
|
||||
pub unsafe extern "C" fn naked_higher_align() {
|
||||
core::arch::naked_asm!("ret")
|
||||
}
|
||||
|
||||
// cold functions follow the same rules as other functions
|
||||
//
|
||||
// in GCC, the `-falign-functions` does not apply to cold functions, but
|
||||
// `-Zmin-function-alignment` applies to all functions.
|
||||
//
|
||||
// CHECK: .balign 16
|
||||
#[no_mangle]
|
||||
#[cold]
|
||||
#[naked]
|
||||
pub unsafe extern "C" fn no_explicit_align_cold() {
|
||||
core::arch::naked_asm!("ret")
|
||||
}
|
||||
Reference in New Issue
Block a user