Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e6d5702
Specify the integer type of the `powi` LLVM intrinsic
tgross35 Jul 12, 2024
82b40c4
Add math intrinsics for `f16` and `f128`
tgross35 Jun 19, 2024
fc43c01
Add math functions for `f16` and `f128`
tgross35 Jun 27, 2024
e18036c
Add `core` functions for `f16` and `f128` that require math routines
tgross35 Jul 17, 2024
4383642
Update comments for `{f16, f32, f64, f128}::midpoint`
tgross35 Jul 18, 2024
8e2ca0c
Add a disclaimer about x86 `f128` math functions
tgross35 Jul 30, 2024
3268b2e
Enable msvc for link-args-order
ChrisDenton Aug 4, 2024
1737845
Enable msvc for run-make/rust-lld
ChrisDenton Aug 4, 2024
131d453
rewrite raw-dylib-alt-calling-conventions to rmake
Oneirical Jul 23, 2024
f31f8c4
rewrite raw-dylib-c to rmake
Oneirical Jul 23, 2024
011727f
rewrite redundant-libs to rmake
Oneirical Jul 23, 2024
0ac3d2e
Add implied target features to target_feature attribute
calebzulawski Jul 26, 2024
a42ec98
Add test to ensure implied target features work with asm, and fix fai…
calebzulawski Jul 26, 2024
82fd5e9
Fix codegen tests
calebzulawski Jul 26, 2024
5077f33
Add missing features
calebzulawski Jul 29, 2024
a3ffd8d
Add +sse4.2 due to #128426
calebzulawski Jul 31, 2024
d00d42f
Bless tests
calebzulawski Jul 31, 2024
0cdc508
Refactor and fill out target feature lists
calebzulawski Aug 2, 2024
d327fdb
Don't use LLVM's target features
calebzulawski Aug 3, 2024
9869a99
Don't use LLVM to compute -Ctarget-feature
calebzulawski Aug 4, 2024
ee7d957
Remove redundant implied features
calebzulawski Aug 4, 2024
9c00b34
Add implied features to non-target-feature functions
calebzulawski Aug 4, 2024
a141d76
Hide implicit target features from diagnostics when possible
calebzulawski Aug 5, 2024
7a78383
Fix typo
calebzulawski Aug 5, 2024
4fad881
Disallow enabling features without their implied features
calebzulawski Aug 6, 2024
342b807
rewrite cross-lang-lto-upstream-rlibs to rmake
Oneirical Jul 25, 2024
fe6feb8
rewrite long-linker-command-lines to rmake
Oneirical Jul 25, 2024
fe4cd9a
rewrite long-linker-command-lines-cmd-exe to rmake
Oneirical Jul 25, 2024
80ee9cf
Rollup merge of #128107 - Oneirical:tomato-hartester, r=jieyouxu
tgross35 Aug 7, 2024
24e0fd7
Rollup merge of #128196 - Oneirical:poltergeist-manitestation, r=jiey…
tgross35 Aug 7, 2024
8b65b64
Rollup merge of #128221 - calebzulawski:implied-target-features, r=Am…
tgross35 Aug 7, 2024
c1d67dc
Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnay
tgross35 Aug 7, 2024
23da5fa
Rollup merge of #128647 - ChrisDenton:link-args-order, r=jieyouxu
tgross35 Aug 7, 2024
b60a578
Rollup merge of #128656 - ChrisDenton:rust-lld, r=lqd
tgross35 Aug 7, 2024
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
Prev Previous commit
Next Next commit
Add test to ensure implied target features work with asm, and fix fai…
…ling tests
  • Loading branch information
calebzulawski committed Aug 6, 2024
commit a42ec982f78ac66e404c8b01248ae100e79e6192
12 changes: 7 additions & 5 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_ast::ast;
use rustc_attr::InstructionSetAttr;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet};
use rustc_errors::Applicability;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
Expand Down Expand Up @@ -99,12 +99,14 @@ pub fn from_target_feature(
}));
}

// Add implied features
// Add both explicit and implied target features, using a set to deduplicate
let mut target_features_set = UnordSet::new();
for feature in added_target_features.iter() {
target_features
.extend(tcx.implied_target_features(*feature).clone().into_sorted_stable_ord());
target_features_set
.extend_unord(tcx.implied_target_features(*feature).clone().into_items());
}
target_features.extend(added_target_features)
target_features_set.extend(added_target_features);
target_features.extend(target_features_set.into_sorted_stable_ord())
}

/// Computes the set of target features used in a function for the purposes of
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-eval/const_fn_target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/const_fn_target_feature.rs:11:24
|
LL | const B: () = unsafe { avx2_fn() };
| ^^^^^^^^^ calling a function that requires unavailable target features: avx2
| ^^^^^^^^^ calling a function that requires unavailable target features: avx, avx2, sse4.1, sse4.2

error: aborting due to 1 previous error

Expand Down
7 changes: 3 additions & 4 deletions tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fn foo() {

#[target_feature(enable = "sse2")]
fn bar() {
sse2();
avx_bmi2();
//~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
Quux.avx_bmi2();
Expand All @@ -43,7 +44,6 @@ fn bar() {
#[target_feature(enable = "avx")]
fn baz() {
sse2();
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
avx_bmi2();
//~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
Quux.avx_bmi2();
Expand All @@ -54,7 +54,8 @@ fn baz() {
#[target_feature(enable = "bmi2")]
fn qux() {
sse2();
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
avx_bmi2();
Quux.avx_bmi2();
}

const _: () = sse2();
Expand All @@ -64,8 +65,6 @@ const _: () = sse2_and_fxsr();
//~^ ERROR call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe

#[deny(unsafe_op_in_unsafe_fn)]
#[target_feature(enable = "avx")]
#[target_feature(enable = "bmi2")]
unsafe fn needs_unsafe_block() {
sse2();
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
Expand Down
60 changes: 22 additions & 38 deletions tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,42 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
= help: in order for the call to be safe, the context requires the following additional target features: sse and sse2
= note: the sse and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`

error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:29:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
= help: in order for the call to be safe, the context requires the following additional target features: avx, sse, sse2, sse3, sse4.1, sse4.2, ssse3, and bmi2
= note: the sse and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`

error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:31:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
= help: in order for the call to be safe, the context requires the following additional target features: avx, sse, sse2, sse3, sse4.1, sse4.2, ssse3, and bmi2
= note: the sse and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`

error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:37:5
--> $DIR/safe-calls.rs:38:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
= help: in order for the call to be safe, the context requires the following additional target features: avx, sse3, sse4.1, sse4.2, ssse3, and bmi2

error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:39:5
--> $DIR/safe-calls.rs:40:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2

error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:45:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
= help: in order for the call to be safe, the context requires the following additional target features: avx, sse3, sse4.1, sse4.2, ssse3, and bmi2

error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:47:5
Expand All @@ -65,52 +58,43 @@ LL | Quux.avx_bmi2();
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2

error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:56:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`

error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:60:15
--> $DIR/safe-calls.rs:61:15
|
LL | const _: () = sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
= help: in order for the call to be safe, the context requires the following additional target features: sse and sse2
= note: the sse and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`

error[E0133]: call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:63:15
--> $DIR/safe-calls.rs:64:15
|
LL | const _: () = sse2_and_fxsr();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: sse2 and fxsr
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
= help: in order for the call to be safe, the context requires the following additional target features: sse, sse2, and fxsr
= note: the fxsr, sse, and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`

error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block
--> $DIR/safe-calls.rs:70:5
--> $DIR/safe-calls.rs:69:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
= help: in order for the call to be safe, the context requires the following additional target features: sse and sse2
= note: the sse and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
note: an unsafe function restricts its caller, but its body is safe by default
--> $DIR/safe-calls.rs:69:1
--> $DIR/safe-calls.rs:68:1
|
LL | unsafe fn needs_unsafe_block() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/safe-calls.rs:66:8
--> $DIR/safe-calls.rs:67:8
|
LL | #[deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 12 previous errors
error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0133`.
10 changes: 10 additions & 0 deletions tests/ui/target-feature/asm-implied-features-issue-128125.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ only-x86_64
//@ build-pass
#![allow(dead_code)]

#[target_feature(enable = "avx2")]
unsafe fn demo(v: std::arch::x86_64::__m256i) {
std::arch::asm!("/* {v} */", v = in(ymm_reg) v);
}

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/target-feature/implied-features.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ only-x86_64
//@ run-pass
//@ build-pass
#![feature(target_feature_11)]
#![allow(dead_code)]

Expand Down