-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #111836 - calebzulawski:target-feature-closure, r=worki…
…ngjubilee Fix #[inline(always)] on closures with target feature 1.1 Fixes #108655. I think this is the most obvious solution that isn't overly complicated. The comment includes more justification, but I think this is likely better than demoting the `#[inline(always)]` to `#[inline]`, since existing code is unaffected.
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// only-x86_64 | ||
// compile-flags: -Copt-level=3 | ||
|
||
#![crate_type = "lib"] | ||
#![feature(target_feature_11)] | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
use std::arch::x86_64::*; | ||
|
||
// CHECK-LABEL: @with_avx | ||
#[no_mangle] | ||
#[cfg(target_arch = "x86_64")] | ||
#[target_feature(enable = "avx")] | ||
fn with_avx(x: __m256) -> __m256 { | ||
// CHECK: fadd | ||
let add = { | ||
#[inline(always)] | ||
|x, y| unsafe { _mm256_add_ps(x, y) } | ||
}; | ||
add(x, x) | ||
} | ||
|
||
// CHECK-LABEL: @without_avx | ||
#[no_mangle] | ||
#[cfg(target_arch = "x86_64")] | ||
unsafe fn without_avx(x: __m256) -> __m256 { | ||
// CHECK-NOT: fadd | ||
let add = { | ||
#[inline(always)] | ||
|x, y| unsafe { _mm256_add_ps(x, y) } | ||
}; | ||
add(x, x) | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Tests #108655: closures in `#[target_feature]` functions can still be marked #[inline(always)] | ||
|
||
// check-pass | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
|
||
#[target_feature(enable = "avx")] | ||
pub unsafe fn test() { | ||
({ | ||
#[inline(always)] | ||
move || {} | ||
})(); | ||
} | ||
|
||
fn main() {} |