about summary refs log tree commit diff
path: root/tests/ui/asm/x86_64
AgeCommit message (Collapse)AuthorLines
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-27/+29
2025-07-23Add `ignore-backends` annotations in failing GCC backend ui testsGuillaume Gomez-0/+1
2025-06-03Remove uses of `stdarch_x86_avx512`sayantn-2/+0
2025-05-18Remove uses of `#[feature(avx512_target_feature)]`sayantn-7/+4
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-3/+3
2025-04-05Update the minimum external LLVM to 19Josh Stone-330/+25
2025-03-17Stabilize asm_gotoGary Guo-4/+3
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-1/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-10Pass InferCtxt to InlineAsmCtxt to properly taint on errorMichael Goulet-9/+15
Split up some of the tests bc tainting causes some errors to become suppressed
2025-02-12Rollup merge of #134090 - veluca93:stable-tf11, r=oli-obkJacob Pratt-2/+0
Stabilize target_feature_11 # Stabilization report This is an updated version of https://github.com/rust-lang/rust/pull/116114, which is itself a redo of https://github.com/rust-lang/rust/pull/99767. Most of this commit and report were copied from those PRs. Thanks ```@LeSeulArtichaut``` and ```@calebzulawski!``` ## Summary Allows for safe functions to be marked with `#[target_feature]` attributes. Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot *generally* be assigned to safe function pointers, and don't implement the `Fn*` traits. However, calling them from other `#[target_feature]` functions with a superset of features is safe. ```rust // Demonstration function #[target_feature(enable = "avx2")] fn avx2() {} fn foo() { // Calling `avx2` here is unsafe, as we must ensure // that AVX is available first. unsafe { avx2(); } } #[target_feature(enable = "avx2")] fn bar() { // Calling `avx2` here is safe. avx2(); } ``` Moreover, once https://github.com/rust-lang/rust/pull/135504 is merged, they can be converted to safe function pointers in a context in which calling them is safe: ```rust // Demonstration function #[target_feature(enable = "avx2")] fn avx2() {} fn foo() -> fn() { // Converting `avx2` to fn() is a compilation error here. avx2 } #[target_feature(enable = "avx2")] fn bar() -> fn() { // `avx2` coerces to fn() here avx2 } ``` See the section "Closures" below for justification of this behaviour. ## Test cases Tests for this feature can be found in [`tests/ui/target_feature/`](https://github.com/rust-lang/rust/tree/f6cb952dc115fd1311b02b694933e31d8dc8b002/tests/ui/target-feature). ## Edge cases ### Closures * [target-feature 1.1: should closures inherit target-feature annotations? #73631](https://github.com/rust-lang/rust/issues/73631) Closures defined inside functions marked with #[target_feature] inherit the target features of their parent function. They can still be assigned to safe function pointers and implement the appropriate `Fn*` traits. ```rust #[target_feature(enable = "avx2")] fn qux() { let my_closure = || avx2(); // this call to `avx2` is safe let f: fn() = my_closure; } ``` This means that in order to call a function with #[target_feature], you must guarantee that the target-feature is available while the function, any closures defined inside it, as well as any safe function pointers obtained from target-feature functions inside it, execute. This is usually ensured because target features are assumed to never disappear, and: - on any unsafe call to a `#[target_feature]` function, presence of the target feature is guaranteed by the programmer through the safety requirements of the unsafe call. - on any safe call, this is guaranteed recursively by the caller. If you work in an environment where target features can be disabled, it is your responsibility to ensure that no code inside a target feature function (including inside a closure) runs after this (until the feature is enabled again). **Note:** this has an effect on existing code, as nowadays closures do not inherit features from the enclosing function, and thus this strengthens a safety requirement. It was originally proposed in #73631 to solve this by adding a new type of UB: “taking a target feature away from your process after having run code that uses that target feature is UB” . This was motivated by userspace code already assuming in a few places that CPU features never disappear from a program during execution (see i.e. https://github.com/rust-lang/stdarch/blob/2e29bdf90832931ea499755bb4ad7a6b0809295a/crates/std_detect/src/detect/arch/x86.rs); however, concerns were raised in the context of the Linux kernel; thus, we propose to relax that requirement to "causing the set of usable features to be reduced is unsafe; when doing so, the programmer is required to ensure that no closures or safe fn pointers that use removed features are still in scope". * [Fix #[inline(always)] on closures with target feature 1.1 #111836](https://github.com/rust-lang/rust/pull/111836) Closures accept `#[inline(always)]`, even within functions marked with `#[target_feature]`. Since these attributes conflict, `#[inline(always)]` wins out to maintain compatibility. ### ABI concerns * [The extern "C" ABI of SIMD vector types depends on target features #116558](https://github.com/rust-lang/rust/issues/116558) The ABI of some types can change when compiling a function with different target features. This could have introduced unsoundness with target_feature_11, but recent fixes (#133102, #132173) either make those situations invalid or make the ABI no longer dependent on features. Thus, those issues should no longer occur. ### Special functions The `#[target_feature]` attribute is forbidden from a variety of special functions, such as main, current and future lang items (e.g. `#[start]`, `#[panic_handler]`), safe default trait implementations and safe trait methods. This was not disallowed at the time of the first stabilization PR for target_features_11, and resulted in the following issues/PRs: * [`#[target_feature]` is allowed on `main` #108645](https://github.com/rust-lang/rust/issues/108645) * [`#[target_feature]` is allowed on default implementations #108646](https://github.com/rust-lang/rust/issues/108646) * [#[target_feature] is allowed on #[panic_handler] with target_feature 1.1 #109411](https://github.com/rust-lang/rust/issues/109411) * [Prevent using `#[target_feature]` on lang item functions #115910](https://github.com/rust-lang/rust/pull/115910) ## Documentation * Reference: [Document the `target_feature_11` feature reference#1181](https://github.com/rust-lang/reference/pull/1181) --- cc tracking issue https://github.com/rust-lang/rust/issues/69098 cc ```@workingjubilee``` cc ```@RalfJung``` r? ```@rust-lang/lang```
2025-02-11Rollup merge of #136239 - folkertdev:show-supported-register-classes, ↵Matthias Krüger-0/+6
r=SparrowLii,jieyouxu show supported register classes in error message a simple diagnostic change that shows the supported register classes when an invalid one is found. This information can be hard to find (especially for unstable targets), and this message now gives at least something to try or search for. I've followed the pattern for invalid clobber ABIs. `@rustbot` label +A-inline-assembly
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-6/+9
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-29show supported register classesFolkert de Vries-0/+6
in inline assembly, show the supported register classes when an invalid one is found
2025-01-27Stabilize target_feature_11Caleb Zulawski-2/+0
2024-11-26Pass end position of span through inline ASM cookiebeetrees-25/+360
2024-11-24Make asm_goto_with_outputs a separate feature gateGary Guo-1/+1
2024-11-24Support use of asm goto with outputs and `options(noreturn)`Gary Guo-2/+22
When labels are present, the `noreturn` option really means that asm block won't fallthrough -- if labels are present, then outputs can still be meaningfully used.
2024-11-24Fix asm goto with outputsGary Guo-9/+37
When outputs are used together with labels, they are considered to be written for all destinations, not only when falling through.
2024-10-11Make asm label blocks safe contextGary Guo-0/+37
`asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out.
2024-09-30make type-check-4 asm tests about non-const expressionsRalf Jung-48/+0
2024-09-26Stabilize `const_refs_to_static`Ding Xiang Fei-42/+25
update tests fix bitwidth-sensitive stderr output use build-fail for asm tests
2024-09-09Ban non-array SIMDScott McMurray-11/+8
2024-08-13stabilize `asm_const`Folkert-61/+51
2024-08-06Auto merge of #125558 - Amanieu:const-asm-type, r=lcnrbors-53/+9
Tweak type inference for `const` operands in inline asm Previously these would be treated like integer literals and default to `i32` if a type could not be determined. To allow for forward-compatibility with `str` constants in the future, this PR changes type inference to use an unbound type variable instead. The actual type checking is deferred until after typeck where we still ensure that the final type for the `const` operand is an integer type. <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> -->
2024-08-01separate test file for invalid sym operandFolkert-53/+9
2024-07-25improve error message when `global_asm!` uses `asm!` optionsFolkert-18/+18
2024-07-25apply fix suggested by lcnrFolkert-16/+16
2024-07-11Account for `let foo = expr`; to suggest `const foo: Ty = expr;`Esteban Küber-6/+6
2024-07-11Use verbose style when suggesting changing `const` with `let`Esteban Küber-9/+15
2024-06-26Automatically taint InferCtxt when errors are emittedOli Scherer-12/+59
2024-06-19Remove c_unwind from tests and fix testsGary Guo-1/+1
2024-06-13Add `f16` and `f128` inline ASM support for `x86` and `x86-64`beetrees-5/+5
2024-05-01Add inline comments why we're forcing the target cpuJosh Stone-4/+5
2024-05-01Use an explicit x86-64 cpu in tests that are sensitive to itJosh Stone-4/+5
There are a few tests that depend on some target features **not** being enabled by default, and usually they are correct with the default x86-64 target CPU. However, in downstream builds we have modified the default to fit our distros -- `x86-64-v2` in RHEL 9 and `x86-64-v3` in RHEL 10 -- and the latter especially trips tests that expect not to have AVX. These cases are few enough that we can just set them back explicitly.
2024-04-10Handle more cases of value suggestionsEsteban Küber-4/+4
2024-04-03Remove MIR unsafe checkMatthew Jasper-27/+2
This also remove safety information from MIR.
2024-03-23Rollup merge of #121940 - veera-sivarajan:bugfix-121593, r=fmeaseJubilee-8/+8
Mention Register Size in `#[warn(asm_sub_register)]` Fixes #121593 Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
2024-03-03Update testsVeera-8/+8
2024-02-24Add tests for asm gotoGary Guo-16/+183
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-48/+48
2024-02-14Implicitly enable evex512 if avx512 is enabledNikita Popov-0/+15
LLVM 18 requires the evex512 feature to allow use of zmm registers. LLVM automatically sets it when using a generic CPU, but not when `-C target-cpu` is specified. This will result either in backend legalization crashes, or code unexpectedly using ymm instead of zmm registers. For now, make sure that `avx512*` features imply `evex512`. Long term we'll probably have to deal with the AVX10 mess somehow.
2024-02-10rebless after rebaseRalf Jung-0/+3
2024-02-10unstably allow constants to refer to statics and read from immutable staticsRalf Jung-10/+19
2024-01-05Remove revisions for THIR unsafeckMatthew Jasper-2/+0
This is to make the diff when stabilizing it easier to review.
2023-11-28Name explicit registers in conflict register errors for inline assemblyGeorge Wort-7/+7
2023-10-19Fix duplicate labels emitted in `render_multispan_macro_backtrace()`Gurinder Singh-6/+1
Using hash set instead of vec to weed out duplicates
2023-10-06Use pushsection/popsectionbjorn3-2/+2
2023-10-05Properly export function defined in test which uses global_asm!()bjorn3-1/+8
Currently the test passes with the LLVM backend as the codegen unit partitioning logic happens to place both the global_asm!() and the function which calls the function defined by the global_asm!() in the same CGU. With the Cranelift backend it breaks however as it will place all assembly in separate codegen units to be passed to an external linker.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-1/+1
2023-07-27Update the minimum external LLVM to 15Josh Stone-1/+0