rust/src/test/assembly
Simonas Kazlauskas 72fb4379d5 Adjust -Ctarget-cpu=native handling in cg_llvm
When cg_llvm encounters the `-Ctarget-cpu=native` it computes an
explciit set of features that applies to the target in order to
correctly compile code for the host CPU (because e.g. `skylake` alone is
not sufficient to tell if some of the instructions are available or
not).

However there were a couple of issues with how we did this. Firstly, the
order in which features were overriden wasn't quite right – conceptually
you'd expect `-Ctarget-cpu=native` option to override the features that
are implicitly set by the target definition. However due to how other
`-Ctarget-cpu` values are handled we must adopt the following order
of priority:

* Features from -Ctarget-cpu=*; are overriden by
* Features implied by --target; are overriden by
* Features from -Ctarget-feature; are overriden by
* function specific features.

Another problem was in that the function level `target-features`
attribute would overwrite the entire set of the globally enabled
features, rather than just the features the
`#[target_feature(enable/disable)]` specified. With something like
`-Ctarget-cpu=native` we'd end up in a situation wherein a function
without `#[target_feature(enable)]` annotation would have a broader
set of features compared to a function with one such attribute. This
turned out to be a cause of heavy run-time regressions in some code
using these function-level attributes in conjunction with
`-Ctarget-cpu=native`, for example.

With this PR rustc is more careful about specifying the entire set of
features for functions that use `#[target_feature(enable/disable)]` or
`#[instruction_set]` attributes.

Sadly testing the original reproducer for this behaviour is quite
impossible – we cannot rely on `-Ctarget-cpu=native` to be anything in
particular on developer or CI machines.
2021-03-16 21:32:55 +02:00
..
asm Support LLVM 12 in rustc 2021-02-28 10:19:44 +01:00
auxiliary Introduce assembly tests 2019-02-27 23:33:05 +01:00
nvptx-arch-default.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-arch-emit-asm.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-arch-link-arg.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-arch-target-cpu.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-atomics.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-internalizing.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-linking-binary.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-linking-cdylib.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
nvptx-safe-naming.rs Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
stack-probes.rs Use probe-stack=inline-asm in LLVM 11+ 2021-01-14 22:49:16 -05:00
target-feature-multiple.rs Adjust -Ctarget-cpu=native handling in cg_llvm 2021-03-16 21:32:55 +02:00
x86_64-fortanix-unknown-sgx-lvi-generic-load.rs cleaning up code 2020-09-25 15:13:55 +02:00
x86_64-fortanix-unknown-sgx-lvi-generic-ret.rs cleaning up code 2020-09-25 15:13:55 +02:00
x86_64-fortanix-unknown-sgx-lvi-inline-assembly.rs rust inline assembly lvi hardening test 2020-09-25 15:02:07 +02:00