Run rustfmt on tests/assembly/.

This commit is contained in:
Nicholas Nethercote 2024-05-29 13:57:23 +10:00
parent 4af4ba2391
commit d063c7b6c8
15 changed files with 52 additions and 85 deletions

View file

@ -14,7 +14,6 @@ ignore = [
# - some contain syntax errors that cause rustfmt to give an error # - some contain syntax errors that cause rustfmt to give an error
# - some UI tests are broken by different formatting # - some UI tests are broken by different formatting
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments) # - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
"/tests/assembly/",
"/tests/auxiliary/", "/tests/auxiliary/",
"/tests/codegen/", "/tests/codegen/",
"/tests/codegen-units/", "/tests/codegen-units/",

View file

@ -1,7 +1,7 @@
//@ assembly-output: emit-asm //@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=1 //@ compile-flags: -Copt-level=1
//@ only-x86_64 //@ only-x86_64
#![crate_type="rlib"] #![crate_type = "rlib"]
// CHECK-LABEL: align_offset_byte_ptr // CHECK-LABEL: align_offset_byte_ptr
// CHECK: leaq 31 // CHECK: leaq 31

View file

@ -5,8 +5,8 @@
#![feature(portable_simd)] #![feature(portable_simd)]
use std::simd::Simd;
use std::arch::asm; use std::arch::asm;
use std::simd::Simd;
#[target_feature(enable = "avx")] #[target_feature(enable = "avx")]
#[no_mangle] #[no_mangle]

View file

@ -18,7 +18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
// CHECK: {{call .*_mm_blend_ps.*}} // CHECK: {{call .*_mm_blend_ps.*}}
// CHECK-NOT: blendps // CHECK-NOT: blendps
// CHECK: ret // CHECK: ret
#[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101) #[inline(never)]
|x, y| _mm_blend_ps(x, y, 0b0101)
}; };
f(x, y) f(x, y)
} }
@ -33,9 +34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
// CHECK: blendps // CHECK: blendps
// CHECK-NOT: _mm_blend_ps // CHECK-NOT: _mm_blend_ps
// CHECK: ret // CHECK: ret
#[inline(never)] |x, y| unsafe { #[inline(never)]
_mm_blend_ps(x, y, 0b0101) |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
}
}; };
f(x, y) f(x, y)
} }
@ -52,9 +52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
// CHECK-NOT: _mm_blend_ps // CHECK-NOT: _mm_blend_ps
// CHECK: ret // CHECK: ret
let f = { let f = {
#[inline] |x, y| unsafe { #[inline]
_mm_blend_ps(x, y, 0b0101) |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
}
}; };
f(x, y) f(x, y)
} }

View file

@ -4,8 +4,7 @@
//@ revisions: opt-speed opt-size //@ revisions: opt-speed opt-size
//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no //@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no //@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
#![crate_type="rlib"] #![crate_type = "rlib"]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(pointer_is_aligned_to)] #![feature(pointer_is_aligned_to)]
@ -16,9 +15,7 @@
// CHECK: retq // CHECK: retq
#[no_mangle] #[no_mangle]
pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool { pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
unsafe { unsafe { std::intrinsics::assume(align.is_power_of_two()) }
std::intrinsics::assume(align.is_power_of_two())
}
ptr.is_aligned_to(align) ptr.is_aligned_to(align)
} }

View file

@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic //@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
//@ [x64] needs-llvm-components: x86 //@ [x64] needs-llvm-components: x86
#![feature(no_core, lang_items)] #![feature(no_core, lang_items)]
#![no_core] #![no_core]
#![crate_type="rlib"] #![crate_type = "rlib"]
#[lang = "sized"] #[lang = "sized"]
trait Sized {} trait Sized {}
@ -17,9 +16,7 @@ trait Copy {}
// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip) // CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
#[no_mangle] #[no_mangle]
pub fn call_other_fn() -> u8 { pub fn call_other_fn() -> u8 {
unsafe { unsafe { other_fn() }
other_fn()
}
} }
// CHECK-LABEL: other_fn: // CHECK-LABEL: other_fn:
@ -27,9 +24,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle] #[no_mangle]
#[inline(never)] #[inline(never)]
pub fn other_fn() -> u8 { pub fn other_fn() -> u8 {
unsafe { unsafe { foreign_fn() }
foreign_fn()
}
} }
extern "C" {fn foreign_fn() -> u8;} extern "C" {
fn foreign_fn() -> u8;
}

View file

@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie //@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
//@ [x64] needs-llvm-components: x86 //@ [x64] needs-llvm-components: x86
#![feature(no_core, lang_items)] #![feature(no_core, lang_items)]
#![no_core] #![no_core]
#![crate_type="rlib"] #![crate_type = "rlib"]
#[lang = "sized"] #[lang = "sized"]
trait Sized {} trait Sized {}
@ -18,9 +17,7 @@ trait Copy {}
// CHECK: {{(jmp|callq)}} other_fn // CHECK: {{(jmp|callq)}} other_fn
#[no_mangle] #[no_mangle]
pub fn call_other_fn() -> u8 { pub fn call_other_fn() -> u8 {
unsafe { unsafe { other_fn() }
other_fn()
}
} }
// CHECK-LABEL: other_fn: // CHECK-LABEL: other_fn:
@ -30,9 +27,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle] #[no_mangle]
#[inline(never)] #[inline(never)]
pub fn other_fn() -> u8 { pub fn other_fn() -> u8 {
unsafe { unsafe { foreign_fn() }
foreign_fn()
}
} }
extern "C" {fn foreign_fn() -> u8;} extern "C" {
fn foreign_fn() -> u8;
}

View file

@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled //@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
#![crate_type = "lib"] #![crate_type = "lib"]
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)] #![feature(unsized_locals, unsized_fn_params)]
// CHECK-LABEL: emptyfn: // CHECK-LABEL: emptyfn:
#[no_mangle] #[no_mangle]
pub fn emptyfn() { pub fn emptyfn() {
@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
// CHECK-LABEL: local_string_addr_taken // CHECK-LABEL: local_string_addr_taken
#[no_mangle] #[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) { pub fn local_string_addr_taken(f: fn(&String)) {
@ -205,7 +201,7 @@ pub struct Gigastruct {
not: u64, not: u64,
have: u64, have: u64,
array: u64, array: u64,
members: u64 members: u64,
} }
// CHECK-LABEL: local_large_var_moved // CHECK-LABEL: local_large_var_moved
@ -259,7 +255,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF // EOF
// ``` // ```
// all: __security_check_cookie // all: __security_check_cookie
// strong: __security_check_cookie // strong: __security_check_cookie
// basic: __security_check_cookie // basic: __security_check_cookie
@ -267,7 +262,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
extern "C" { extern "C" {
// A call to an external `alloca` function is *not* recognized as an // A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the // `alloca(3)` operation. This function is a compiler built-in, as the
@ -320,7 +314,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
// CHECK-LABEL: alloca_dynamic_arg // CHECK-LABEL: alloca_dynamic_arg
#[no_mangle] #[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -340,7 +333,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature: // this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. // https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param // CHECK-LABEL: unsized_fn_param
#[no_mangle] #[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@ -354,7 +346,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
// alloca, and is therefore not protected by the `strong` or `basic` // alloca, and is therefore not protected by the `strong` or `basic`
// heuristics. // heuristics.
// We should have a __security_check_cookie call in `all` and `strong` modes but // We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet // LLVM does not support generating stack protectors in functions with funclet
// based EH personalities. // based EH personalities.

View file

@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled //@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
#![crate_type = "lib"] #![crate_type = "lib"]
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![feature(unsized_locals, unsized_fn_params)] #![feature(unsized_locals, unsized_fn_params)]
// CHECK-LABEL: emptyfn: // CHECK-LABEL: emptyfn:
#[no_mangle] #[no_mangle]
pub fn emptyfn() { pub fn emptyfn() {
@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
// CHECK-LABEL: local_string_addr_taken // CHECK-LABEL: local_string_addr_taken
#[no_mangle] #[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) { pub fn local_string_addr_taken(f: fn(&String)) {
@ -213,7 +209,7 @@ pub struct Gigastruct {
not: u64, not: u64,
have: u64, have: u64,
array: u64, array: u64,
members: u64 members: u64,
} }
// CHECK-LABEL: local_large_var_moved // CHECK-LABEL: local_large_var_moved
@ -267,7 +263,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF // EOF
// ``` // ```
// all: __security_check_cookie // all: __security_check_cookie
// strong: __security_check_cookie // strong: __security_check_cookie
// basic: __security_check_cookie // basic: __security_check_cookie
@ -275,7 +270,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
extern "C" { extern "C" {
// A call to an external `alloca` function is *not* recognized as an // A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the // `alloca(3)` operation. This function is a compiler built-in, as the
@ -328,7 +322,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __security_check_cookie // missing-NOT: __security_check_cookie
} }
// CHECK-LABEL: alloca_dynamic_arg // CHECK-LABEL: alloca_dynamic_arg
#[no_mangle] #[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -348,7 +341,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature: // this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. // https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param // CHECK-LABEL: unsized_fn_param
#[no_mangle] #[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@ -362,7 +354,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
// alloca, and is therefore not protected by the `strong` or `basic` // alloca, and is therefore not protected by the `strong` or `basic`
// heuristics. // heuristics.
// We should have a __security_check_cookie call in `all` and `strong` modes but // We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet // LLVM does not support generating stack protectors in functions with funclet
// based EH personalities. // based EH personalities.

View file

@ -143,7 +143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __stack_chk_fail // missing-NOT: __stack_chk_fail
} }
// CHECK-LABEL: local_string_addr_taken // CHECK-LABEL: local_string_addr_taken
#[no_mangle] #[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) { pub fn local_string_addr_taken(f: fn(&String)) {
@ -194,7 +193,7 @@ pub struct Gigastruct {
not: u64, not: u64,
have: u64, have: u64,
array: u64, array: u64,
members: u64 members: u64,
} }
// CHECK-LABEL: local_large_var_moved // CHECK-LABEL: local_large_var_moved
@ -255,7 +254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __stack_chk_fail // missing-NOT: __stack_chk_fail
} }
extern "C" { extern "C" {
// A call to an external `alloca` function is *not* recognized as an // A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the // `alloca(3)` operation. This function is a compiler built-in, as the
@ -308,7 +306,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __stack_chk_fail // missing-NOT: __stack_chk_fail
} }
// CHECK-LABEL: alloca_dynamic_arg // CHECK-LABEL: alloca_dynamic_arg
#[no_mangle] #[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@ -328,7 +325,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature: // this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. // https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
// CHECK-LABEL: unsized_fn_param // CHECK-LABEL: unsized_fn_param
#[no_mangle] #[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@ -342,7 +338,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
// alloca, and is therefore not protected by the `strong` or `basic` // alloca, and is therefore not protected by the `strong` or `basic`
// heuristics. // heuristics.
// all: __stack_chk_fail // all: __stack_chk_fail
// strong-NOT: __stack_chk_fail // strong-NOT: __stack_chk_fail
// basic-NOT: __stack_chk_fail // basic-NOT: __stack_chk_fail

View file

@ -9,15 +9,15 @@
#![feature(no_core, lang_items)] #![feature(no_core, lang_items)]
#![no_core] #![no_core]
#![crate_type="rlib"] #![crate_type = "rlib"]
#[lang="sized"] #[lang = "sized"]
trait Sized {} trait Sized {}
#[lang="copy"] #[lang = "copy"]
trait Copy {} trait Copy {}
#[lang="sync"] #[lang = "sync"]
trait Sync {} trait Sync {}
#[lang = "drop_in_place"] #[lang = "drop_in_place"]
@ -42,9 +42,7 @@ extern "C" {
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles] // A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles]
#[no_mangle] #[no_mangle]
pub fn banana() -> u8 { pub fn banana() -> u8 {
unsafe { unsafe { *(chaenomeles as *mut u8) }
*(chaenomeles as *mut u8)
}
} }
// CHECK-LABEL: peach: // CHECK-LABEL: peach:
@ -53,9 +51,7 @@ pub fn banana() -> u8 {
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana] // A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana]
#[no_mangle] #[no_mangle]
pub fn peach() -> u8 { pub fn peach() -> u8 {
unsafe { unsafe { *(banana as *mut u8) }
*(banana as *mut u8)
}
} }
// CHECK-LABEL: mango: // CHECK-LABEL: mango:
@ -65,9 +61,7 @@ pub fn peach() -> u8 {
// A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA] // A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
#[no_mangle] #[no_mangle]
pub fn mango() -> u8 { pub fn mango() -> u8 {
unsafe { unsafe { *EXOCHORDA }
*EXOCHORDA
}
} }
// CHECK-LABEL: orange: // CHECK-LABEL: orange:

View file

@ -4,5 +4,4 @@
// CHECK: main // CHECK: main
pub fn main() { pub fn main() {}
}

View file

@ -8,7 +8,7 @@
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
extern { extern "C" {
fn may_panic(); fn may_panic();
#[rustc_nounwind] #[rustc_nounwind]
@ -19,7 +19,9 @@ struct LogOnDrop;
impl Drop for LogOnDrop { impl Drop for LogOnDrop {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { log_number(0); } unsafe {
log_number(0);
}
} }
} }
@ -27,7 +29,9 @@ impl Drop for LogOnDrop {
#[no_mangle] #[no_mangle]
pub fn test_cleanup() { pub fn test_cleanup() {
let _log_on_drop = LogOnDrop; let _log_on_drop = LogOnDrop;
unsafe { may_panic(); } unsafe {
may_panic();
}
// CHECK-NOT: call // CHECK-NOT: call
// CHECK: try // CHECK: try
@ -41,12 +45,16 @@ pub fn test_cleanup() {
#[no_mangle] #[no_mangle]
pub fn test_rtry() { pub fn test_rtry() {
unsafe { unsafe {
core::intrinsics::catch_unwind(|_| { core::intrinsics::catch_unwind(
may_panic(); |_| {
}, core::ptr::null_mut(), |data, exception| { may_panic();
log_number(data as usize); },
log_number(exception as usize); core::ptr::null_mut(),
}); |data, exception| {
log_number(data as usize);
log_number(exception as usize);
},
);
} }
// CHECK-NOT: call // CHECK-NOT: call

View file

@ -5,7 +5,7 @@
//@ only-x86_64-fortanix-unknown-sgx //@ only-x86_64-fortanix-unknown-sgx
#[no_mangle] #[no_mangle]
pub extern fn plus_one(r: &mut u64) { pub extern "C" fn plus_one(r: &mut u64) {
*r = *r + 1; *r = *r + 1;
} }

View file

@ -5,7 +5,7 @@
//@ only-x86_64-fortanix-unknown-sgx //@ only-x86_64-fortanix-unknown-sgx
#[no_mangle] #[no_mangle]
pub extern fn myret() {} pub extern "C" fn myret() {}
// CHECK: myret: // CHECK: myret:
// CHECK: popq [[REGISTER:%[a-z]+]] // CHECK: popq [[REGISTER:%[a-z]+]]
// CHECK-NEXT: lfence // CHECK-NEXT: lfence