<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/test/codegen/target-feature-multiple.rs, branch try</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2021-03-16T19:32:55+00:00</updated>
<entry>
<title>Adjust `-Ctarget-cpu=native` handling in cg_llvm</title>
<updated>2021-03-16T19:32:55+00:00</updated>
<author>
<name>Simonas Kazlauskas</name>
<email>git@kazlauskas.me</email>
</author>
<published>2021-03-13T13:29:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=72fb4379d56b93b9bd0149649a74fb4b5465ec18'/>
<id>urn:sha1:72fb4379d56b93b9bd0149649a74fb4b5465ec18</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>cmdline: Make target features individually overridable</title>
<updated>2020-05-10T23:04:53+00:00</updated>
<author>
<name>Vadim Petrochenkov</name>
<email>vadim.petrochenkov@gmail.com</email>
</author>
<published>2020-05-10T21:16:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=00dcb665e7ede908ba11638e8230340f396674f8'/>
<id>urn:sha1:00dcb665e7ede908ba11638e8230340f396674f8</id>
<content type='text'>
</content>
</entry>
</feed>
