Skip to content

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

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
merged 1 commit into from
Jul 7, 2025

Conversation

xdoardo
Copy link
Contributor

@xdoardo xdoardo commented Jun 29, 2025

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). Currently, rustc does not allow to specify custom address spaces and does not take into consideration p- specifications in the datalayout string.

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

@rustbot
Copy link
Collaborator

rustbot commented Jun 29, 2025

workingjubilee is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Jun 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 29, 2025

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in compiler/rustc_ast_lowering/src/format.rs

cc @m-ou-se

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred in cfg and check-cfg configuration

cc @Urgau

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@workingjubilee
Copy link
Member

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 29, 2025

⌛ Trying commit ef6e4ef with merge a6d8fc2

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 29, 2025
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 target 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: the potential performance drawbacks of not having ad-hoc fields will be tested in this PR's CI run.

r? workingjubilee
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 29, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 29, 2025

☀️ Try build successful (CI)
Build commit: a6d8fc2 (a6d8fc279459764136b16847f5b4411d4298525d, parent: 5ca574e85b67cec0a6fc3fddfe398cbe676c9c69)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a6d8fc2): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.0% [0.7%, 1.7%] 8
Regressions ❌
(secondary)
2.0% [0.9%, 4.7%] 38
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [0.7%, 1.7%] 8

Max RSS (memory usage)

Results (primary -2.6%, secondary -8.0%)

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)
- - 0
Improvements ✅
(primary)
-2.6% [-3.6%, -1.5%] 2
Improvements ✅
(secondary)
-8.0% [-8.0%, -8.0%] 1
All ❌✅ (primary) -2.6% [-3.6%, -1.5%] 2

Cycles

Results (secondary 2.6%)

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.6% [2.4%, 2.7%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 695.013s -> 695.668s (0.09%)
Artifact size: 371.77 MiB -> 372.01 MiB (0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 29, 2025

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@workingjubilee
Copy link
Member

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jun 29, 2025

⌛ Trying commit fce06e3 with merge 92687cf

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 29, 2025
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
@rust-bors
Copy link

rust-bors bot commented Jun 29, 2025

☀️ Try build successful (CI)
Build commit: 92687cf (92687cf86ed4b58afb2653d78a1c735272295f02, parent: ed2d759783dc9de134bbb3f01085b1e6dbf539f3)

@workingjubilee

This comment was marked as outdated.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 30, 2025
@workingjubilee

This comment was marked as outdated.

@workingjubilee
Copy link
Member

@rust-timer build 92687cf

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (92687cf): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.6%] 4
Regressions ❌
(secondary)
1.1% [0.3%, 1.9%] 29
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.4%, 0.6%] 4

Max RSS (memory usage)

Results (primary -2.3%, secondary 2.1%)

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.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-2.3% [-3.1%, -1.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.3% [-3.1%, -1.4%] 2

Cycles

Results (primary -1.1%, secondary 0.3%)

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)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
-1.1% [-1.2%, -0.9%] 2
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 1
All ❌✅ (primary) -1.1% [-1.2%, -0.9%] 2

Binary size

Results (secondary 0.0%)

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)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 694.715s -> 695.8s (0.16%)
Artifact size: 371.77 MiB -> 371.86 MiB (0.02%)

@workingjubilee

This comment was marked as duplicate.

@rust-bors

This comment was marked as duplicate.

@workingjubilee

This comment was marked as duplicate.

@rust-bors

This comment was marked as duplicate.

@workingjubilee
Copy link
Member

workingjubilee commented Jul 5, 2025

quickly trying the usual culprits of rejections

@bors2 try jobs=test-various,armhf-gnu,i686-gnu-1,i686-msvc-1,x86_64-msvc-1

@rust-bors
Copy link

rust-bors bot commented Jul 5, 2025

⌛ Trying commit 9701efb with merge 03c8605

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 5, 2025
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
try-job: test-various
try-job: armhf-gnu
try-job: i686-gnu-1
try-job: i686-msvc-1
try-job: x86_64-msvc-1
@rust-bors
Copy link

rust-bors bot commented Jul 6, 2025

☀️ Try build successful (CI)
Build commit: 03c8605 (03c8605a59703578ccb6a8297428f108fb1fec96, parent: 175e04331be56c5b4bdf77478434b1a5e0556770)

@xdoardo
Copy link
Contributor Author

xdoardo commented Jul 7, 2025

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 7, 2025
@workingjubilee
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

📌 Commit 93f1201 has been approved by workingjubilee

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

bors commented Jul 7, 2025

⌛ Testing commit 93f1201 with merge 2f8eeb2...

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

☔ The latest upstream changes (presumably #143582) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 7, 2025
@workingjubilee
Copy link
Member

bitrotty.

@bors rollup=iffy p=1

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

☀️ Test successful - checks-actions
Approved by: workingjubilee
Pushing 2f8eeb2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 7, 2025
@bors bors merged commit 2f8eeb2 into rust-lang:master Jul 7, 2025
12 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 7, 2025
Copy link
Contributor

github-actions bot commented Jul 7, 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 1b0bc59 (parent) -> 2f8eeb2 (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 2f8eeb2bba86b8f457ec602c578473c711f85628 --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. dist-apple-various: 7932.5s -> 5516.0s (-30.5%)
  2. x86_64-apple-1: 6904.1s -> 8544.1s (23.8%)
  3. x86_64-mingw-1: 10358.2s -> 8583.5s (-17.1%)
  4. x86_64-apple-2: 6156.3s -> 6784.3s (10.2%)
  5. dist-sparcv9-solaris: 5475.3s -> 4940.6s (-9.8%)
  6. dist-armhf-linux: 5217.2s -> 4736.9s (-9.2%)
  7. dist-x86_64-msvc-alt: 8165.4s -> 8872.2s (8.7%)
  8. dist-powerpc-linux: 5365.8s -> 4924.6s (-8.2%)
  9. x86_64-gnu-llvm-20-3: 7442.9s -> 6834.5s (-8.2%)
  10. dist-x86_64-apple: 9821.2s -> 9072.3s (-7.6%)
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 (2f8eeb2): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.4%, secondary -1.9%)

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

mean range count
Regressions ❌
(primary)
2.4% [1.2%, 3.6%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.9% [-1.9%, -1.9%] 1
All ❌✅ (primary) 2.4% [1.2%, 3.6%] 2

Cycles

Results (primary 4.1%, secondary -0.8%)

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

mean range count
Regressions ❌
(primary)
4.1% [4.1%, 4.1%] 1
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-3.6%, -3.6%] 1
All ❌✅ (primary) 4.1% [4.1%, 4.1%] 1

Binary size

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

Bootstrap: 464.431s -> 465.909s (0.32%)
Artifact size: 372.18 MiB -> 372.26 MiB (0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

8 participants