rust/compiler
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
..
rustc Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix 2021-03-08 13:13:22 +01:00
rustc_apfloat
rustc_arena Update the bootstrap compiler 2021-02-20 17:19:30 -05:00
rustc_ast Rollup merge of #82841 - hvdijk:x32, r=joshtriplett 2021-03-09 09:05:24 +00:00
rustc_ast_lowering Rollup merge of #82854 - estebank:issue-82827, r=oli-obk 2021-03-08 20:09:02 +01:00
rustc_ast_passes Add help for matches for if let in arm guard 2021-03-07 14:44:21 -08:00
rustc_ast_pretty Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011 2021-02-19 02:49:08 +01:00
rustc_attr Auto merge of #71481 - estebank:inherit-stability, r=nikomatsakis 2021-03-05 05:28:07 +00:00
rustc_builtin_macros Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011 2021-03-08 13:13:23 +01:00
rustc_codegen_cranelift Clean up todos 2021-03-09 19:31:31 +00:00
rustc_codegen_llvm Adjust -Ctarget-cpu=native handling in cg_llvm 2021-03-16 21:32:55 +02:00
rustc_codegen_ssa Remove the -Zinsert-sideeffect 2021-03-10 12:21:43 +02:00
rustc_data_structures Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelix 2021-03-07 23:45:57 +00:00
rustc_driver Bump tracing-tree dependency 2021-03-09 16:44:51 +00:00
rustc_error_codes Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomez 2021-03-04 20:01:01 +09:00
rustc_errors Change x64 size checks to not apply to x32. 2021-03-06 16:02:48 +00:00
rustc_expand Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011 2021-03-08 13:13:23 +01:00
rustc_feature Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #82841 - hvdijk:x32, r=joshtriplett 2021-03-09 09:05:24 +00:00
rustc_hir_pretty Auto merge of #81611 - cjgillot:meowner, r=estebank 2021-02-16 22:14:32 +00:00
rustc_incremental Print -Ztime-passes (and misc stats/logs) on stderr, not stdout. 2021-02-18 14:13:38 +02:00
rustc_index Miscellaneous inlining improvements 2021-02-26 00:00:00 +00:00
rustc_infer Change x64 size checks to not apply to x32. 2021-03-06 16:02:48 +00:00
rustc_interface Remove the -Zinsert-sideeffect 2021-03-10 12:21:43 +02:00
rustc_lexer
rustc_lint Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov 2021-03-09 09:05:20 +00:00
rustc_lint_defs Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
rustc_llvm Schedule ThinLTOBuffer passes again after sanitizer passes 2021-03-03 20:48:37 +01:00
rustc_macros replaced some map_or with map_or_else 2021-02-24 02:43:35 +03:00
rustc_metadata Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelix 2021-03-07 23:45:57 +00:00
rustc_middle Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
rustc_mir Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplett 2021-03-10 08:01:32 +09:00
rustc_mir_build Rollup merge of #82841 - hvdijk:x32, r=joshtriplett 2021-03-09 09:05:24 +00:00
rustc_parse Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov 2021-03-09 09:05:20 +00:00
rustc_parse_format
rustc_passes Rollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomez 2021-03-07 10:41:13 +09:00
rustc_plugin_impl Only store a LocalDefId in hir::Item. 2021-02-15 19:32:10 +01:00
rustc_privacy Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726 2021-02-18 16:57:34 +01:00
rustc_query_impl Simplify hashing. 2021-02-21 12:22:22 +01:00
rustc_query_system Simplify hashing. 2021-02-21 12:22:22 +01:00
rustc_resolve Rollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebank 2021-03-10 08:01:37 +09:00
rustc_save_analysis Only store a LocalDefId in hir::ForeignItem. 2021-02-15 19:32:29 +01:00
rustc_serialize Update the bootstrap compiler 2021-02-20 17:19:30 -05:00
rustc_session Remove the -Zinsert-sideeffect 2021-03-10 12:21:43 +02:00
rustc_span Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011 2021-03-08 13:13:23 +01:00
rustc_symbol_mangling Use less HirId when referring to items. 2021-02-15 19:36:12 +01:00
rustc_target Rollup merge of #82733 - Yn0ga:master, r=estebank 2021-03-10 08:01:29 +09:00
rustc_trait_selection Rollup merge of #82841 - hvdijk:x32, r=joshtriplett 2021-03-09 09:05:24 +00:00
rustc_traits Fix tests 2021-03-03 11:22:44 +01:00
rustc_ty_utils Auto merge of #82159 - BoxyUwU:uwu, r=varkor 2021-02-24 21:54:52 +00:00
rustc_type_ir New pass to deduplicate blocks 2021-02-21 21:51:54 +01:00
rustc_typeck Rollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebank 2021-03-10 08:01:37 +09:00