Skip to content
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

Rollup of 7 pull requests #117180

Merged
merged 17 commits into from
Oct 25, 2023
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ff7bf79
Migrate inline_compatibility.rs test to FileCheck
tmiasko Oct 20, 2023
b3cfd5b
Precommit target features compatibility test
tmiasko Oct 20, 2023
011b260
Require target features to match exactly during inlining
tmiasko Oct 20, 2023
bc18509
coverage: UI test for unstable value `-C instrument-coverage=branch`
Zalathar Oct 25, 2023
65b0f6a
Remove support for alias `-Z instrument-coverage`
Zalathar Oct 24, 2023
2334143
Fix unwrap suggestion for async fn
compiler-errors Oct 25, 2023
beaf46f
Work around the fact that `check_mod_type_wf` may spuriously return `…
oli-obk Oct 25, 2023
32339f8
implement C ABI lowering for CSKY
Dirreke Oct 25, 2023
a9fad1c
compiletest: Display compilation errors in mir-opt tests
tmiasko Oct 25, 2023
268ec72
Make `Iterator` a lang item
oli-obk Oct 23, 2023
24254d2
Rollup merge of #117111 - Zalathar:zinstrument, r=compiler-errors
matthiaskrgr Oct 25, 2023
a1ab167
Rollup merge of #117141 - tmiasko:inline-target-features, r=oli-obk
matthiaskrgr Oct 25, 2023
585a122
Rollup merge of #117152 - compiler-errors:no-ret-coercion, r=chenyukang
matthiaskrgr Oct 25, 2023
74c2b98
Rollup merge of #117154 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3
matthiaskrgr Oct 25, 2023
26a9e08
Rollup merge of #117159 - oli-obk:error_shenanigans, r=estebank
matthiaskrgr Oct 25, 2023
beba522
Rollup merge of #117163 - tmiasko:compiletest-mir-opt, r=compiler-errors
matthiaskrgr Oct 25, 2023
b0521fe
Rollup merge of #117173 - oli-obk:gen_fn_split2, r=compiler-errors
matthiaskrgr Oct 25, 2023
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
6 changes: 2 additions & 4 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
@@ -438,10 +438,8 @@ impl<'tcx> Inliner<'tcx> {
return Err("incompatible instruction set");
}

for feature in &callee_attrs.target_features {
if !self.codegen_fn_attrs.target_features.contains(feature) {
return Err("incompatible target feature");
}
if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
return Err("incompatible target features");
}

Ok(())

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.

64 changes: 42 additions & 22 deletions tests/mir-opt/inline/inline_compatibility.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,71 @@
// 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
// CHECK-LABEL: fn f2()
// CHECK: bb0: {
// CHECK-NEXT: nop()
#[target_feature(enable = "avx")]
pub unsafe fn f2() {
nop();
}

#[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;