rust/compiler/rustc_codegen_llvm/src
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
..
back Auto merge of #83084 - nagisa:nagisa/features-native, r=petrochenkov 2021-03-17 05:46:08 +00:00
coverageinfo Don't directly expose coverage::CounterMappingRegion via FFI 2021-03-01 23:35:35 +01:00
debuginfo Auto merge of #82285 - nhwn:nonzero-debug, r=nagisa 2021-03-07 20:23:23 +00:00
llvm Add support for storing code model to LLVM module IR 2021-03-12 11:02:25 +09:00
abi.rs Support LLVM 12 in rustc 2021-02-28 10:19:44 +01:00
allocator.rs Remove redundant to_string calls 2021-02-17 11:25:55 +01:00
asm.rs Always lower asm! to valid HIR 2021-03-13 20:49:32 +00:00
attributes.rs Adjust -Ctarget-cpu=native handling in cg_llvm 2021-03-16 21:32:55 +02:00
base.rs Update and improve rustc_codegen_{llvm,ssa} docs 2020-12-22 19:42:23 -08:00
builder.rs Replace const_cstr with cstr crate 2021-02-14 09:45:35 +11:00
callee.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
common.rs Update and improve rustc_codegen_{llvm,ssa} docs 2020-12-22 19:42:23 -08:00
consts.rs Replace const_cstr with cstr crate 2021-02-14 09:45:35 +11:00
context.rs Add support for storing code model to LLVM module IR 2021-03-12 11:02:25 +09:00
declare.rs Make declare_cfn more flexible 2021-01-23 17:19:49 -05:00
intrinsic.rs Remove the -Zinsert-sideeffect 2021-03-10 12:21:43 +02:00
lib.rs rustc: Stabilize -Zrun-dsymutil as -Csplit-debuginfo 2021-01-28 08:51:11 -08:00
llvm_util.rs Adjust -Ctarget-cpu=native handling in cg_llvm 2021-03-16 21:32:55 +02:00
metadata.rs fix review 2021-02-25 04:21:12 +03:00
mono_item.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
type_.rs Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
type_of.rs Revert "cg_llvm: fewer_names in uncached_llvm_type" 2020-12-17 16:40:47 +00:00
va_arg.rs Add big-endian support for AArch64 va_arg 2021-01-27 22:47:56 +00:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00