Skip to content

Run rustfmt on src/test/codegen/ folder #34001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/test/codegen/adjustments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@
// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
#[no_mangle]
fn helper(_: usize) {
}
fn helper(_: usize) {}

// CHECK-LABEL: @no_op_slice_adjustment
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
// check that we copy directly to the return value slot
// CHECK: [[SRC:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %x to
// CHECK: [[DST:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %sret_slot to i8*
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[DST]], i8* [[SRC]],
{ x }
// CHECK: [[SRC:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %x to
// CHECK: [[DST:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %sret_slot to i8*
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[DST]], i8* [[SRC]],
{
x
}
}

// CHECK-LABEL: @no_op_slice_adjustment2
#[no_mangle]
pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the function's return value, so check
// that there's no memcpy (the slice is written to sret_slot element-wise)
// CHECK-NOT: call void @llvm.memcpy.
// CHECK-NOT: call void @llvm.memcpy.
no_op_slice_adjustment(x)
}
2 changes: 1 addition & 1 deletion src/test/codegen/coercions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static X: i32 = 5;
// CHECK-NOT: alloca
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32{
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32 {
&X as *const i32
}

Expand Down
11 changes: 5 additions & 6 deletions src/test/codegen/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
// CHECK: @const{{[0-9]+}} = {{.*}}, align 4

#[derive(Copy, Clone)]

// repr(i16) is required for the {low,high}_align_const test
#[repr(i16)]
pub enum E<A, B> {
Expand All @@ -42,7 +41,7 @@ pub static STATIC: E<i16, i32> = E::A(0);
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn static_enum_const() -> E<i16, i32> {
STATIC
STATIC
}

// CHECK-LABEL: @inline_enum_const
Expand All @@ -56,16 +55,16 @@ pub fn inline_enum_const() -> E<i8, i16> {
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn low_align_const() -> E<i16, [i16; 3]> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]+}}, i8* {{.*}} [[LOW_HIGH:@const[0-9]+]]
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]+}}, i8* {{.*}} [[LOW_HIGH:@const[0-9]+]]
E::A(0)
}

// CHECK-LABEL: @high_align_const
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn high_align_const() -> E<i16, i32> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]}}, i8* {{.*}} [[LOW_HIGH]]
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]}}, i8* {{.*}} [[LOW_HIGH]]
E::A(0)
}
32 changes: 15 additions & 17 deletions src/test/codegen/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,28 @@
struct SomeUniqueName;

impl Drop for SomeUniqueName {
fn drop(&mut self) {
}
fn drop(&mut self) {}
}

pub fn possibly_unwinding() {
}
pub fn possibly_unwinding() {}

// CHECK-LABEL: @droppy
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn droppy() {
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
// regular function exit. We used to have problems with quadratic growths of drop calls in such
// functions.
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK-NOT: call{{.*}}SomeUniqueName{{.*}}drop
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is too long.

// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
// regular function exit. We used to have problems with quadratic growths of drop calls in such
// functions.
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
// CHECK-NOT: call{{.*}}SomeUniqueName{{.*}}drop
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
let _s = SomeUniqueName;
possibly_unwinding();
let _s = SomeUniqueName;
Expand Down
10 changes: 5 additions & 5 deletions src/test/codegen/extern-functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#![crate_type = "lib"]
#![feature(unwind_attributes)]

extern {
// CHECK: Function Attrs: nounwind
// CHECK-NEXT: declare void @extern_fn
extern "C" {
// CHECK: Function Attrs: nounwind
// CHECK-NEXT: declare void @extern_fn
fn extern_fn();
// CHECK-NOT: Function Attrs: nounwind
// CHECK: declare void @unwinding_extern_fn
// CHECK-NOT: Function Attrs: nounwind
// CHECK: declare void @unwinding_extern_fn
#[unwind]
fn unwinding_extern_fn();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/fatptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ pub trait T {}
// CHECK-LABEL: @copy_fat_ptr
#[no_mangle]
pub fn copy_fat_ptr(x: &T) {
// CHECK-NOT: extractvalue
// CHECK-NOT: extractvalue
let x2 = x;
}
30 changes: 11 additions & 19 deletions src/test/codegen/float_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,40 @@
#![crate_type = "lib"]
#![feature(core_intrinsics)]

use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};

// CHECK-LABEL: @add
#[no_mangle]
pub fn add(x: f32, y: f32) -> f32 {
// CHECK: fadd float
// CHECK-NOT fast
// CHECK: fadd float
// CHECK-NOT fast
x + y
}

// CHECK-LABEL: @addition
#[no_mangle]
pub fn addition(x: f32, y: f32) -> f32 {
// CHECK: fadd fast float
unsafe {
fadd_fast(x, y)
}
// CHECK: fadd fast float
unsafe { fadd_fast(x, y) }
}

// CHECK-LABEL: @subtraction
#[no_mangle]
pub fn subtraction(x: f32, y: f32) -> f32 {
// CHECK: fsub fast float
unsafe {
fsub_fast(x, y)
}
// CHECK: fsub fast float
unsafe { fsub_fast(x, y) }
}

// CHECK-LABEL: @multiplication
#[no_mangle]
pub fn multiplication(x: f32, y: f32) -> f32 {
// CHECK: fmul fast float
unsafe {
fmul_fast(x, y)
}
// CHECK: fmul fast float
unsafe { fmul_fast(x, y) }
}

// CHECK-LABEL: @division
#[no_mangle]
pub fn division(x: f32, y: f32) -> f32 {
// CHECK: fdiv fast float
unsafe {
fdiv_fast(x, y)
}
// CHECK: fdiv fast float
unsafe { fdiv_fast(x, y) }
}
61 changes: 22 additions & 39 deletions src/test/codegen/function-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,133 +14,116 @@
#![feature(allocator)]

pub struct S {
_field: [i64; 4],
_field: [i64; 4],
}

pub struct UnsafeInner {
_field: std::cell::UnsafeCell<i16>,
_field: std::cell::UnsafeCell<i16>,
}

// CHECK: zeroext i1 @boolean(i1 zeroext)
#[no_mangle]
pub fn boolean(x: bool) -> bool {
x
x
}

// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4))
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
pub fn readonly_borrow(_: &i32) {
}
pub fn readonly_borrow(_: &i32) {}

// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4))
// static borrow may be captured
#[no_mangle]
pub fn static_borrow(_: &'static i32) {
}
pub fn static_borrow(_: &'static i32) {}

// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4))
// borrow with named lifetime may be captured
#[no_mangle]
pub fn named_borrow<'r>(_: &'r i32) {
}
pub fn named_borrow<'r>(_: &'r i32) {}

// CHECK: @unsafe_borrow(%UnsafeInner* dereferenceable(2))
// unsafe interior means this isn't actually readonly and there may be aliases ...
#[no_mangle]
pub fn unsafe_borrow(_: &UnsafeInner) {
}
pub fn unsafe_borrow(_: &UnsafeInner) {}

// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2))
// ... unless this is a mutable borrow, those never alias
// ... except that there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
}
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {}

// CHECK: @mutable_borrow(i32* dereferenceable(4))
// FIXME #25759 This should also have `nocapture`
// ... there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
pub fn mutable_borrow(_: &mut i32) {
}
pub fn mutable_borrow(_: &mut i32) {}

// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32))
#[no_mangle]
pub fn indirect_struct(_: S) {
}
pub fn indirect_struct(_: S) {}

// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32))
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
pub fn borrowed_struct(_: &S) {
}
pub fn borrowed_struct(_: &S) {}

// CHECK: noalias dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4))
#[no_mangle]
pub fn _box(x: Box<i32>) -> Box<i32> {
x
x
}

// CHECK: @struct_return(%S* noalias nocapture sret dereferenceable(32))
#[no_mangle]
pub fn struct_return() -> S {
S {
_field: [0, 0, 0, 0]
}
S { _field: [0, 0, 0, 0] }
}

// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
#[no_mangle]
fn helper(_: usize) {
}
fn helper(_: usize) {}

// CHECK: @slice(i8* noalias nonnull readonly, [[USIZE]])
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn slice(_: &[u8]) {
}
fn slice(_: &[u8]) {}

// CHECK: @mutable_slice(i8* nonnull, [[USIZE]])
// FIXME #25759 This should also have `nocapture`
// ... there's this LLVM bug that forces us to not use noalias, see #29485
#[no_mangle]
fn mutable_slice(_: &mut [u8]) {
}
fn mutable_slice(_: &mut [u8]) {}

// CHECK: @unsafe_slice(%UnsafeInner* nonnull, [[USIZE]])
// unsafe interior means this isn't actually readonly and there may be aliases ...
#[no_mangle]
pub fn unsafe_slice(_: &[UnsafeInner]) {
}
pub fn unsafe_slice(_: &[UnsafeInner]) {}

// CHECK: @str(i8* noalias nonnull readonly, [[USIZE]])
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn str(_: &[u8]) {
}
fn str(_: &[u8]) {}

// CHECK: @trait_borrow(i8* nonnull, void (i8*)** nonnull)
// FIXME #25759 This should also have `nocapture`
#[no_mangle]
fn trait_borrow(_: &Drop) {
}
fn trait_borrow(_: &Drop) {}

// CHECK: @trait_box(i8* noalias nonnull, void (i8*)** nonnull)
#[no_mangle]
fn trait_box(_: Box<Drop>) {
}
fn trait_box(_: Box<Drop>) {}

// CHECK: { i16*, [[USIZE]] } @return_slice(i16* noalias nonnull readonly, [[USIZE]])
#[no_mangle]
fn return_slice(x: &[u16]) -> &[u16] {
x
x
}

// CHECK: noalias i8* @allocator()
#[no_mangle]
#[allocator]
pub fn allocator() -> *const i8 {
std::ptr::null()
std::ptr::null()
}
4 changes: 3 additions & 1 deletion src/test/codegen/intrinsic-no-unnamed-attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ extern "rust-intrinsic" {
// CHECK: @llvm.sqrt.f32(float) #{{[0-9]*}}

fn main() {
unsafe { sqrtf32(0.0f32); }
unsafe {
sqrtf32(0.0f32);
}
}
2 changes: 1 addition & 1 deletion src/test/codegen/link_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub static VAR1: u32 = 1;

pub enum E {
A(u32),
B(f32)
B(f32),
}

// CHECK: @VAR2 = constant {{.*}} { i32 0, i32 666, {{.*}} }, section ".test_two"
Expand Down
Loading