Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync rustc_codegen_cranelift #112671

Merged
merged 118 commits into from
Jun 15, 2023
Merged

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Jun 15, 2023

The main highlights this time are a cranelift update, some x86 vendor intrinsic implementations and preparations for testing cg_clif in CI here.

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler

oli-obk and others added 30 commits April 17, 2023 09:14
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
This makes it possible to use liballoc/libstd in combination with
`--emit obj` if you use `#[global_allocator]`. Making it work for the
default libstd allocator would require weak functions, which are not
well supported on all systems.
You will need to add the following as replacement for the old __rust_*
definitions when not using the alloc shim.

    #[no_mangle]
    static __rust_no_alloc_shim_is_unstable: u8 = 0;
bjorn3 and others added 11 commits June 13, 2023 16:39
This makes it easier for ./x.py to vendor all dependencies
Ignore `core`, `alloc` and `test` tests that require unwinding on `-C panic=abort`

Some of the tests for `core` and `alloc` require unwinding through their use of `catch_unwind`. These tests fail when testing using `-C panic=abort` (in my case through a target without unwinding support, and `-Z panic-abort-tests`), while they should be ignored as they don't indicate a failure.

This PR marks all of these tests with this attribute:

```rust
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
```

I'm not aware of a way to test this on rust-lang/rust's CI, as we don't test any target with `-C panic=abort`, but I tested this locally on a Ferrocene target and it does indeed make the test suite pass.
Support testing of cg_clif in rust's CI
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend labels Jun 15, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Jun 15, 2023

@bors r+ p=1

@bors
Copy link
Contributor

bors commented Jun 15, 2023

📌 Commit 8a120cc has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2023
@bors
Copy link
Contributor

bors commented Jun 15, 2023

⌛ Testing commit 8a120cc with merge 114fb86...

@bors
Copy link
Contributor

bors commented Jun 15, 2023

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing 114fb86 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 15, 2023
@bors bors merged commit 114fb86 into rust-lang:master Jun 15, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 15, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (114fb86): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.5%, 2.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-3.5%, -2.1%] 2
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.9% [-4.6%, -1.0%] 9
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.9%] 1
All ❌✅ (primary) -1.9% [-4.6%, 2.5%] 11

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 648.056s -> 648.365s (0.05%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.