diff options
| author | Ralf Jung <post@ralfj.de> | 2025-01-08 09:23:40 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-01-08 09:23:40 +0100 |
| commit | 2d180714e14b34e36bf883bdf706ebaf5fa96754 (patch) | |
| tree | 36b4829675d832d323283fc37457f6509f8a519c /tests/codegen/min-function-alignment.rs | |
| parent | fc4a52f598f6259a98964aa3290e9e74e396c1e3 (diff) | |
| parent | 67f49010adf4ec3238564ec072b3652179813dd1 (diff) | |
| download | rust-2d180714e14b34e36bf883bdf706ebaf5fa96754.tar.gz rust-2d180714e14b34e36bf883bdf706ebaf5fa96754.zip | |
Merge from rustc
Diffstat (limited to 'tests/codegen/min-function-alignment.rs')
| -rw-r--r-- | tests/codegen/min-function-alignment.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/codegen/min-function-alignment.rs b/tests/codegen/min-function-alignment.rs new file mode 100644 index 00000000000..7c0ad12402a --- /dev/null +++ b/tests/codegen/min-function-alignment.rs @@ -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() {} |
