rust/compiler
bors 0c341226ad Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkov
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.

cc https://github.com/rust-lang/rust/issues/83027 `@BurntSushi`
2021-03-17 05:46:08 +00:00
..
rustc Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix 2021-03-08 13:13:22 +01:00
rustc_apfloat
rustc_arena Update to rustc-rayon 0.3.1 2021-03-10 17:53:35 -08:00
rustc_ast Rollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov 2021-03-15 16:22:57 +01:00
rustc_ast_lowering Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisa 2021-03-16 10:05:46 +00:00
rustc_ast_passes Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
rustc_ast_pretty
rustc_attr
rustc_builtin_macros Bump recursion_limit in a few places 2021-03-14 23:02:01 -04:00
rustc_codegen_cranelift s/ConstantSource/ConstantKind/ 2021-03-15 12:06:52 +00:00
rustc_codegen_llvm Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkov 2021-03-17 05:46:08 +00:00
rustc_codegen_ssa Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_data_structures Auto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum 2021-03-15 08:49:25 +00:00
rustc_driver Add rustc_interface::interface::Config::parse_sess_created 2021-03-15 18:24:58 +08:00
rustc_error_codes
rustc_errors Change x64 size checks to not apply to x32. 2021-03-06 16:02:48 +00:00
rustc_expand Introduce proc_macro_back_compat lint, and emit for time-macros-impl 2021-03-14 21:31:46 -04:00
rustc_feature Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #82898 - oli-obk:tait_🧊, r=nikomatsakis 2021-03-16 04:24:48 +00:00
rustc_hir_pretty Use BTreeMap to store attributes. 2021-03-09 19:28:01 +01:00
rustc_incremental Deduplicate unchecked_attrs errors. 2021-03-09 19:28:00 +01:00
rustc_index Remove useless Clone bound in IndexVec. 2021-03-09 18:51:36 +01:00
rustc_infer Change x64 size checks to not apply to x32. 2021-03-06 16:02:48 +00:00
rustc_interface Rollup merge of #83144 - hyd-dev:parse-sess-created, r=oli-obk 2021-03-15 16:23:00 +01:00
rustc_lexer
rustc_lint Introduce proc_macro_back_compat lint, and emit for time-macros-impl 2021-03-14 21:31:46 -04:00
rustc_lint_defs Introduce proc_macro_back_compat lint, and emit for time-macros-impl 2021-03-14 21:31:46 -04:00
rustc_llvm Auto merge of #83044 - kubo39:set-llvm-code-model, r=nikic 2021-03-14 11:46:57 +00:00
rustc_macros Add inlining. 2021-03-11 12:24:43 +01:00
rustc_metadata Iterate on crate_inherent_impls for metadata. 2021-03-13 14:17:55 +01:00
rustc_middle Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_mir Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_mir_build Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_parse Auto merge of #83074 - Aaron1011:new-sort-fix, r=jackh726 2021-03-15 06:20:24 +00:00
rustc_parse_format
rustc_passes Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco 2021-03-15 16:22:52 +01:00
rustc_plugin_impl Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_privacy Remove hir::MacroDef::attrs. 2021-03-09 19:09:36 +01:00
rustc_query_impl Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_query_system Auto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum 2021-03-15 08:49:25 +00:00
rustc_resolve Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor 2021-03-15 16:22:50 +01:00
rustc_save_analysis Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_serialize
rustc_session Bump recursion_limit in a few places 2021-03-14 23:02:01 -04:00
rustc_span Replace type_alias_impl_trait by min_type_alias_impl_trait with no actual changes in behaviour 2021-03-15 17:32:43 +00:00
rustc_symbol_mangling rustc_target: add "unwind" payloads to Abi 2021-03-09 14:38:29 -05:00
rustc_target Address review comments 2021-03-14 23:21:03 +00:00
rustc_trait_selection Auto merge of #82936 - oli-obk:valtree, r=RalfJung,lcnr,matthewjasper 2021-03-16 22:42:56 +00:00
rustc_traits
rustc_ty_utils
rustc_type_ir
rustc_typeck Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis 2021-03-16 19:19:06 +00:00