Skip to content

Commit

Permalink
Run rustfmt on tests/assembly/.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed May 30, 2024
1 parent 4af4ba2 commit d063c7b
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 85 deletions.
1 change: 0 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,6 @@ ignore = [
# - some contain syntax errors that cause rustfmt to give an error
# - some UI tests are broken by different formatting
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
"/tests/assembly/",
"/tests/auxiliary/",
"/tests/codegen/",
"/tests/codegen-units/",
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/align_offset.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=1
//@ only-x86_64
#![crate_type="rlib"]
#![crate_type = "rlib"]

// CHECK-LABEL: align_offset_byte_ptr
// CHECK: leaq 31
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/asm/inline-asm-avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 5,8 @@

#![feature(portable_simd)]

use std::simd::Simd;
use std::arch::asm;
use std::simd::Simd;

#[target_feature(enable = "avx")]
#[no_mangle]
Expand Down
13 changes: 6 additions & 7 deletions tests/assembly/closure-inherit-target-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
// CHECK: {{call .*_mm_blend_ps.*}}
// CHECK-NOT: blendps
// 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)
}
Expand All @@ -33,9 34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
// CHECK: blendps
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
#[inline(never)] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline(never)]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}
Expand All @@ -52,9 52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
let f = {
#[inline] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}
7 changes: 2 additions & 5 deletions tests/assembly/is_aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 4,7 @@
//@ revisions: opt-speed opt-size
//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
#![crate_type="rlib"]

#![crate_type = "rlib"]
#![feature(core_intrinsics)]
#![feature(pointer_is_aligned_to)]

Expand All @@ -16,9 15,7 @@
// CHECK: retq
#[no_mangle]
pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
unsafe {
std::intrinsics::assume(align.is_power_of_two())
}
unsafe { std::intrinsics::assume(align.is_power_of_two()) }
ptr.is_aligned_to(align)
}

Expand Down
15 changes: 6 additions & 9 deletions tests/assembly/pic-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
//@ [x64] needs-llvm-components: x86


#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]

#[lang = "sized"]
trait Sized {}
Expand All @@ -17,19 16,17 @@ trait Copy {}
// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}

// CHECK-LABEL: other_fn:
// CHECK: callq *foreign_fn@GOTPCREL(%rip)
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}

extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}
15 changes: 6 additions & 9 deletions tests/assembly/pie-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
//@ [x64] needs-llvm-components: x86


#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]

#[lang = "sized"]
trait Sized {}
Expand All @@ -18,9 17,7 @@ trait Copy {}
// CHECK: {{(jmp|callq)}} other_fn
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}

// CHECK-LABEL: other_fn:
Expand All @@ -30,9 27,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}

extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled

#![crate_type = "lib"]

#![allow(incomplete_features)]

#![feature(unsized_locals, unsized_fn_params)]


// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
Expand Down Expand Up @@ -139,7 136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -205,7 201,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -259,15 255,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```


// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
// none-NOT: __security_check_cookie
// missing-NOT: __security_check_cookie
}


extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the
Expand Down Expand Up @@ -320,7 314,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
Expand All @@ -340,7 333,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.


// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
Expand All @@ -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`
// heuristics.


// 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
// based EH personalities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled

#![crate_type = "lib"]

#![allow(incomplete_features)]

#![feature(unsized_locals, unsized_fn_params)]


// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
Expand Down Expand Up @@ -139,7 136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -213,7 209,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -267,15 263,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```


// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
// none-NOT: __security_check_cookie
// missing-NOT: __security_check_cookie
}


extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the
Expand Down Expand Up @@ -328,7 322,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
Expand All @@ -348,7 341,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.


// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
Expand All @@ -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`
// heuristics.


// 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
// based EH personalities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __stack_chk_fail
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -194,7 193,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -255,7 254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __stack_chk_fail
}


extern "C" {
// A call to an external `alloca` function is *not* recognized as an
// `alloca(3)` operation. This function is a compiler built-in, as the
Expand Down Expand Up @@ -308,7 306,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
// missing-NOT: __stack_chk_fail
}


// CHECK-LABEL: alloca_dynamic_arg
#[no_mangle]
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
Expand All @@ -328,7 325,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
// this is support for the "unsized locals" unstable feature:
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.


// CHECK-LABEL: unsized_fn_param
#[no_mangle]
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
Expand All @@ -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`
// heuristics.


// all: __stack_chk_fail
// strong-NOT: __stack_chk_fail
// basic-NOT: __stack_chk_fail
Expand Down
20 changes: 7 additions & 13 deletions tests/assembly/static-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 9,15 @@

#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]

#[lang="sized"]
#[lang = "sized"]
trait Sized {}

#[lang="copy"]
#[lang = "copy"]
trait Copy {}

#[lang="sync"]
#[lang = "sync"]
trait Sync {}

#[lang = "drop_in_place"]
Expand All @@ -42,9 42,7 @@ extern "C" {
// A64-NEXT: ldrb {{[a-z0-9] }}, {{\[}}[[REG]], :lo12:chaenomeles]
#[no_mangle]
pub fn banana() -> u8 {
unsafe {
*(chaenomeles as *mut u8)
}
unsafe { *(chaenomeles as *mut u8) }
}

// CHECK-LABEL: peach:
Expand All @@ -53,9 51,7 @@ pub fn banana() -> u8 {
// A64-NEXT: ldrb {{[a-z0-9] }}, {{\[}}[[REG2]], :lo12:banana]
#[no_mangle]
pub fn peach() -> u8 {
unsafe {
*(banana as *mut u8)
}
unsafe { *(banana as *mut u8) }
}

// CHECK-LABEL: mango:
Expand All @@ -65,9 61,7 @@ pub fn peach() -> u8 {
// A64-NEXT: ldr {{[a-z0-9] }}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
#[no_mangle]
pub fn mango() -> u8 {
unsafe {
*EXOCHORDA
}
unsafe { *EXOCHORDA }
}

// CHECK-LABEL: orange:
Expand Down
Loading

0 comments on commit d063c7b

Please sign in to comment.