Skip to content

GCC backend subtree update #144893

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

Merged

Conversation

GuillaumeGomez
Copy link
Member

cc @antoyo

bjorn3 and others added 30 commits July 3, 2025 14:28
Most uses of it either contain a fat or thin lto module. Only
WorkItem::LTO could contain both, but splitting that enum variant
doesn't complicate things much.
…ilee

Allow custom default address spaces and parse `p-` specifications in the datalayout string

Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout).

This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications.

The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run.

r? workingjubilee
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#132469 (Do not suggest borrow that is already there in fully-qualified call)
 - rust-lang#143340 (awhile -> a while where appropriate)
 - rust-lang#143438 (Fix the link in `rustdoc.md`)
 - rust-lang#143539 (Regression tests for repr ICEs)
 - rust-lang#143566 (Fix `x86_64-unknown-netbsd` platform support page)
 - rust-lang#143572 (Remove unused allow attrs)
 - rust-lang#143583 (`loop_match`: fix 'no terminator on block')
 - rust-lang#143584 (make `Machine::load_mir` infallible)
 - rust-lang#143591 (Fix missing words in future tracking issue)

r? `@ghost`
`@rustbot` modify labels: rollup
…rrors

Various refactors to the LTO handling code

In particular reducing the sharing of code paths between fat and thin-LTO and making the fat LTO implementation more self-contained. This also moves some autodiff handling out of cg_ssa into cg_llvm given that Enzyme only works with LLVM anyway and an implementation for another backend may do things entirely differently. This will also make it a bit easier to split LTO handling out of the coordinator thread main loop into a separate loop, which should reduce the complexity of the coordinator thread.
…compiler-errors

fix `-Zsanitizer=kcfi` on `#[naked]` functions

fixes rust-lang#143266

With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call).

My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`.

r? codegen
````@rustbot```` label +A-naked
cc ````@maurer```` ````@rcvalle````
The modules vec can already contain serialized modules and there is no
need to distinguish between cached and non-cached cgus at LTO time.
And move exported_symbols_for_lto call from backends to cg_ssa.
@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2025

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@GuillaumeGomez
Copy link
Member Author

Forgot to assign ghost, sorry about that.

r? ghost

@GuillaumeGomez
Copy link
Member Author

@bors r+ p=1 rollup=never

@bors
Copy link
Collaborator

bors commented Aug 4, 2025

📌 Commit 21bd677 has been approved by GuillaumeGomez

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 Aug 4, 2025
@bors
Copy link
Collaborator

bors commented Aug 4, 2025

⌛ Testing commit 21bd677 with merge 0060d5a...

@bors
Copy link
Collaborator

bors commented Aug 4, 2025

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing 0060d5a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 4, 2025
@bors bors merged commit 0060d5a into rust-lang:master Aug 4, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 4, 2025
Copy link
Contributor

github-actions bot commented Aug 4, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing e1b9081 (parent) -> 0060d5a (this PR)

Test differences

Show 3 test diffs

3 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 0060d5a2a8a86a31f6299311fe64b1d755a91c4f --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-2: 5847.6s -> 3863.2s (-33.9%)
  2. dist-aarch64-linux: 7970.9s -> 5590.5s (-29.9%)
  3. x86_64-apple-1: 6578.9s -> 8131.3s (23.6%)
  4. pr-check-2: 2731.0s -> 2242.1s (-17.9%)
  5. aarch64-gnu-llvm-19-2: 2647.1s -> 2213.9s (-16.4%)
  6. aarch64-gnu-debug: 4276.0s -> 3603.6s (-15.7%)
  7. x86_64-gnu-llvm-19: 2900.7s -> 2528.9s (-12.8%)
  8. i686-gnu-1: 8179.4s -> 7202.0s (-11.9%)
  9. i686-gnu-nopt-1: 7983.2s -> 7089.2s (-11.2%)
  10. pr-check-1: 1714.3s -> 1525.6s (-11.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0060d5a): 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 (secondary -0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.5%, -1.6%] 2
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 468.82s -> 466.337s (-0.53%)
Artifact size: 376.96 MiB -> 376.97 MiB (0.00%)

@GuillaumeGomez GuillaumeGomez deleted the subtree-update_cg_gcc_2025-08-04 branch August 5, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-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.