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

Stop using LLVM struct types for array/pointer offset GEPs #122325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

erikdesjardins
Copy link
Contributor

...and just use a byte array with the same size as the element type instead. This avoids depending on LLVM's struct layout to determine the size of the array/pointer element.

Spiritually split out from #121577.

r? @nikic

This avoids depending on LLVM's struct types to determine the size of
the array/pointer element.
@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 Mar 11, 2024
@saethlin
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2024
@bors
Copy link
Contributor

bors commented Mar 11, 2024

⌛ Trying commit 379de30 with merge 7ba692d...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2024
Stop using LLVM struct types for array/pointer offset GEPs

...and just use a byte array with the same size as the element type instead. This avoids depending on LLVM's struct layout to determine the size of the array/pointer element.

Spiritually split out from rust-lang#121577.

r? `@nikic`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 11, 2024

☀️ Try build successful - checks-actions
Build commit: 7ba692d (7ba692d484ffb437afc774f11309f398ff2ab358)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ba692d): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-2.4%, -1.4%] 4
All ❌✅ (primary) - - 0

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)
2.4% [1.0%, 3.7%] 12
Regressions ❌
(secondary)
2.7% [1.6%, 3.8%] 23
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [-2.0%, 3.7%] 13

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-9.6% [-9.9%, -9.3%] 4
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 647.708s -> 643.848s (-0.60%)
Artifact size: 309.95 MiB -> 309.65 MiB (-0.10%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2024
GCC uses a start/end pointer instead of the index-based loop on LLVM,
so it has a "GEP" here that needs to be converted for consistency with
project_index
@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2024

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@nikic
Copy link
Contributor

nikic commented Mar 12, 2024

I'm not sure this is a particularly useful change to make at this time.

@erikdesjardins
Copy link
Contributor Author

This isn't really about ptradd anymore. I want to get to a point where we never use LLVM struct types except for scalarpair returns†, which feels like it's almost within reach. That should make it a lot harder for us to accidentally leak Rust/LLVM implementation details into our ABIs, or to create completely broken ABIs like wasm32-unknown-unknown. (In this specific case, it also just feels silly that we generate these full-fidelity types, and then the only thing LLVM does is add up all the fields to compute the size, something we already did.)

But given that this pattern is likely to get a proper untyped representation in the future (with scaled ptradd or something), I'm fine if you want to wait for that.

† ...and a few unfortunate special cases: volatile load/store, unadjusted ABI, wasm32-unknown-unknown, and surely some things I haven't found yet that won't be easily changed.

@wesleywiser
Copy link
Member

@nikic Do you think we should wait for a proper untyped representation in LLVM IR as @erikdesjardins mentions or should we consider merging this?

@nikic
Copy link
Contributor

nikic commented Jul 18, 2024

I think it's better to wait. LLVM still has some source element type dependent logic for variable index GEPs, and I don't think there's much benefit to making this change early.

@apiraino
Copy link
Contributor

apiraino commented Nov 7, 2024

As per the previous comment, I'll try signaling this with:

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

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. 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.

9 participants