Skip to content

Commit

Permalink
Migrate inline_compatibility.rs test to FileCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Oct 24, 2023
1 parent 98b4a64 commit ff7bf79
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 226 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

56 changes: 34 additions & 22 deletions tests/mir-opt/inline/inline_compatibility.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
// skip-filecheck
// Checks that only functions with compatible attributes are inlined.
//
// only-x86_64
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Cpanic=abort

#![crate_type = "lib"]
#![feature(no_sanitize)]
#![feature(target_feature_11)]
#![feature(c_variadic)]

// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff
#[inline]
#[target_feature(enable = "sse2")]
unsafe fn sse2() {}

#[inline]
fn nop() {}

// CHECK-LABEL: fn f0()
// CHECK: bb0: {
// CHECK-NEXT: return;
#[target_feature(enable = "sse2")]
pub unsafe fn inlined_target_feature() {
target_feature();
pub unsafe fn f0() {
sse2();
}

// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff
pub unsafe fn not_inlined_target_feature() {
target_feature();
// CHECK-LABEL: fn f1()
// CHECK: bb0: {
// CHECK-NEXT: sse2()
pub unsafe fn f1() {
sse2();
}

// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff
#[inline]
#[no_sanitize(address)]
pub unsafe fn no_sanitize() {}

// CHECK-LABEL: fn inlined_no_sanitize()
// CHECK: bb0: {
// CHECK-NEXT: return;
#[no_sanitize(address)]
pub unsafe fn inlined_no_sanitize() {
no_sanitize();
}

// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff
// CHECK-LABEL: fn not_inlined_no_sanitize()
// CHECK: bb0: {
// CHECK-NEXT: no_sanitize()
pub unsafe fn not_inlined_no_sanitize() {
no_sanitize();
}

#[inline]
#[target_feature(enable = "sse2")]
pub unsafe fn target_feature() {}

#[inline]
#[no_sanitize(address)]
pub unsafe fn no_sanitize() {}

// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff
// CHECK-LABEL: fn not_inlined_c_variadic()
// CHECK: bb0: {
// CHECK-NEXT: StorageLive(_1)
// CHECK-NEXT: _1 = sum
pub unsafe fn not_inlined_c_variadic() {
let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32);
let _ = sum(4u32, 4u32, 30u32, 200u32, 1000u32);
}

#[no_mangle]
#[inline(always)]
#[no_mangle]
unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
let mut s = 0;
let mut i = 0;
Expand Down

0 comments on commit ff7bf79

Please sign in to comment.