Skip to content

Conversation

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Oct 16, 2025

Part of #146411

Fixes #119729
Keeps #136175 as it involves offset_of! which this PR does not touch.

r? @ghost

@rustbot rustbot added 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 16, 2025
@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

@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 Oct 16, 2025
rust-bors bot added a commit that referenced this pull request Oct 16, 2025
Replace NullOp::SizeOf and NullOp::AlignOf by lang items.
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 17, 2025

☀️ Try build successful (CI)
Build commit: 2cefd8f (2cefd8ff4961f18771f6f840878942cbfbc03afe, parent: 53a741fc4b8cf2d8e7b1b2336ed8edf889db84f4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2cefd8f): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.5% [0.4%, 0.6%] 3
Regressions ❌
(secondary)
0.7% [0.5%, 0.7%] 4
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 2
Improvements ✅
(secondary)
-0.2% [-0.7%, -0.1%] 14
All ❌✅ (primary) 0.2% [-0.2%, 0.6%] 5

Max RSS (memory usage)

Results (primary -0.3%, secondary -1.4%)

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

mean range count
Regressions ❌
(primary)
1.5% [0.4%, 3.0%] 8
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.4% [-7.6%, -1.1%] 5
Improvements ✅
(secondary)
-1.4% [-2.2%, -0.8%] 3
All ❌✅ (primary) -0.3% [-7.6%, 3.0%] 13

Cycles

Results (primary -2.9%, secondary 6.8%)

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

Binary size

Results (primary -0.0%, 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.1% [0.0%, 0.5%] 22
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 11
Improvements ✅
(primary)
-0.2% [-0.8%, -0.0%] 18
Improvements ✅
(secondary)
-1.2% [-3.2%, -0.3%] 4
All ❌✅ (primary) -0.0% [-0.8%, 0.5%] 40

Bootstrap: 475.105s -> 474.369s (-0.15%)
Artifact size: 390.35 MiB -> 390.39 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 17, 2025
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Oct 17, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot force-pushed the no-null-op branch 2 times, most recently from fca4c69 to 27154a0 Compare October 17, 2025 17:59
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Oct 21, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

let ty = self.monomorphize(ty);
let layout = bx.cx().layout_of(ty);
let val = match null_op {
mir::NullOp::SizeOf => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No action) I do like that this means the different backends don't need this any more, which is nice since it all needs to match what CTFE did anyway 👍

_2 = SizeOf(S);
_3 = AlignOf(S);
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue];
_2 = alloc::alloc::exchange_malloc(const <S as std::mem::SizedTypeProperties>::SIZE, const <S as std::mem::SizedTypeProperties>::ALIGN) -> [return: bb1, unwind continue];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely to see this inline and no longer need the locals 👍

+ _4 = const 4_usize;
+ _5 = const 4_usize;
+ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> [return: bb1, unwind unreachable];
_4 = alloc::alloc::exchange_malloc(const <i32 as std::mem::SizedTypeProperties>::SIZE, const <i32 as std::mem::SizedTypeProperties>::ALIGN) -> [return: bb1, unwind unreachable];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming: the reason this is still the const, rather than 4_usize is that this is a GVN unit test? Some other pass is going to evaluate it in the normal flow, right?

Or does it not matter because anything asking for try_eval_target_usize on the const will get the value either way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's because GVN avoids to evaluate constants in-place. That does not really matter, any code that needs to evaluate it will easily. If we need it, it's a 3-line change in GVN, but I'd rather do it in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely don't think it's GVN's problem. If it's useful to do, I'd probably do it in InstSimplify or something, since it could be done locally. Agreed no need for it in this PR.

And TBH I don't know how important it is. I did a bit more digging, and it looks like try_eval_target_usize will end up in const_eval_resolve+const_eval_global_id, so probably anyone looking at the constant will get the value they need anyway, so might not be worth bothering.

(I don't know if there are paths that only look at Const::Val and skip Const::Unevaluated, though. I guess we can always worry about that later if needed.)

So I think this can be "won't fix"ed.

Comment on lines -1027 to -1030
/// Returns the size of a value of that type.
SizeOf,
/// Returns the minimum alignment of a type.
AlignOf,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @celinval

Copy link
Member

@scottmcm scottmcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments along the way, but this looks good to me. r=me with minor updates to address things if you see fit. (Or wait for oli if you think this should go through someone more knowledgeable about const stuff.)

View changes since this review

@bors
Copy link
Collaborator

bors commented Oct 22, 2025

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

@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cjgillot
Copy link
Contributor Author

@bors r=scottmcm,oli-obk

@bors
Copy link
Collaborator

bors commented Oct 23, 2025

📌 Commit 5dfbf67 has been approved by scottmcm,oli-obk

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

bors commented Oct 23, 2025

⌛ Testing commit 5dfbf67 with merge 4b3ba58...

@bors
Copy link
Collaborator

bors commented Oct 23, 2025

☀️ Test successful - checks-actions
Approved by: scottmcm,oli-obk
Pushing 4b3ba58 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 23, 2025
@bors bors merged commit 4b3ba58 into rust-lang:master Oct 23, 2025
12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 23, 2025
@github-actions
Copy link
Contributor

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 7838ce1 (parent) -> 4b3ba58 (this PR)

Test differences

Show 52 test diffs

Stage 1

  • [crashes] tests/crashes/114663.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/119729.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/136175.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait-2.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait-3.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait.rs: [missing] -> pass (J1)

Stage 2

  • [crashes] tests/crashes/114663.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/119729.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/136175.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait-2.rs: [missing] -> pass (J2)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait-3.rs: [missing] -> pass (J2)
  • [ui] tests/ui/const-generics/generic_const_exprs/size_of-dyn-trait.rs: [missing] -> pass (J2)

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

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 4b3ba5844e8831c9b3ee5a5643cdff5da0677426 --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. aarch64-apple: 8512.0s -> 6923.8s (-18.7%)
  2. x86_64-gnu-llvm-20: 2404.1s -> 2842.5s (18.2%)
  3. dist-x86_64-apple: 7185.0s -> 6096.5s (-15.2%)
  4. dist-aarch64-apple: 6702.2s -> 5767.2s (-14.0%)
  5. dist-various-2: 2223.4s -> 1967.1s (-11.5%)
  6. armhf-gnu: 4926.0s -> 5489.8s (11.4%)
  7. dist-armhf-linux: 4864.6s -> 5321.3s (9.4%)
  8. x86_64-gnu-llvm-20-1: 3236.2s -> 3521.1s (8.8%)
  9. x86_64-gnu-gcc: 3136.2s -> 3411.5s (8.8%)
  10. arm-android: 5820.1s -> 6227.1s (7.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 (4b3ba58): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2% [0.1%, 0.5%] 3
Regressions ❌
(secondary)
0.3% [0.1%, 0.7%] 30
Improvements ✅
(primary)
-0.4% [-0.7%, -0.1%] 4
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.1%] 5
All ❌✅ (primary) -0.1% [-0.7%, 0.5%] 7

Max RSS (memory usage)

Results (primary -0.1%, 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.2% [0.5%, 4.8%] 5
Regressions ❌
(secondary)
3.5% [0.6%, 6.3%] 18
Improvements ✅
(primary)
-2.3% [-4.3%, -1.2%] 5
Improvements ✅
(secondary)
-1.8% [-3.0%, -0.8%] 8
All ❌✅ (primary) -0.1% [-4.3%, 4.8%] 10

Cycles

Results (primary 1.3%, secondary -1.5%)

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

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
5.3% [1.7%, 9.2%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-13.1%, -2.0%] 15
All ❌✅ (primary) 1.3% [1.3%, 1.3%] 1

Binary size

Results (primary -0.0%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.4%] 21
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 11
Improvements ✅
(primary)
-0.1% [-0.8%, -0.0%] 19
Improvements ✅
(secondary)
-0.6% [-0.8%, -0.3%] 3
All ❌✅ (primary) -0.0% [-0.8%, 0.4%] 40

Bootstrap: 473.667s -> 474.933s (0.27%)
Artifact size: 390.66 MiB -> 390.48 MiB (-0.05%)

@cjgillot cjgillot deleted the no-null-op branch October 23, 2025 10:12
tautschnig added a commit to tautschnig/kani that referenced this pull request Oct 24, 2025
Relevant upstream PR:
- rust-lang/rust#147793 (Replace NullOp::SizeOf and
NullOp::AlignOf by lang items.)

Resolves: model-checking#4425
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. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

internal compiler error: SizeOf MIR operator called for unsized type dyn Send

9 participants