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

Treat static refs as mir::ConstantKind::Val #93800

Merged
merged 7 commits into from
Feb 16, 2022

Conversation

b-naber
Copy link
Contributor

@b-naber b-naber commented Feb 9, 2022

With the upcoming introduction of Valtrees we want to treat more values as mir::ConstantKind::Val directly.

r? @lcnr

cc @oli-obk

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 9, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2022
@b-naber b-naber changed the title Treat static initialisers as mir::ConstantKind::Val Treat static refs as mir::ConstantKind::Val Feb 9, 2022
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 9, 2022

lgtm

r=me with 32 bit mir dumps blessed (this is why CI is failing)

@rust-log-analyzer

This comment has been minimized.

@b-naber
Copy link
Contributor Author

b-naber commented Feb 9, 2022

r=me with 32 bit mir dumps blessed (this is why CI is failing)

Not sure how to do that. I'm on Mac OS and tried a complete rebuild with: ./x.py test src/test/mir-opt --bless --target i686-apple-darwin, but that fails to build the std with a linker error?!

@oli-obk
Copy link
Contributor

oli-obk commented Feb 9, 2022

I can try pushing to your branch tomorrow. I wish we could just tell bors to bless or have a bot that scrapes the blessed files from CI

@b-naber
Copy link
Contributor Author

b-naber commented Feb 14, 2022

@oli-obk This is ready.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 14, 2022

-.- I need a a way to set reminders for myself when I write such comments.

Thanks for going the hard way and copying from CI

@bors r+

@bors
Copy link
Contributor

bors commented Feb 14, 2022

📌 Commit 5e36b5daa5aa4960d8198bf0d6d6926051f47201 has been approved by oli-obk

@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 Feb 14, 2022
@b-naber
Copy link
Contributor Author

b-naber commented Feb 14, 2022

-.- I need a a way to set reminders for myself when I write such comments.

No worries.

@bors
Copy link
Contributor

bors commented Feb 15, 2022

☔ The latest upstream changes (presumably #93148) 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 Feb 15, 2022
@b-naber b-naber force-pushed the static-initializers-mir-val branch from 5e36b5d to e9c0763 Compare February 15, 2022 20:25
@rust-log-analyzer

This comment has been minimized.

@b-naber b-naber force-pushed the static-initializers-mir-val branch 2 times, most recently from b99f38c to b8a065d Compare February 15, 2022 20:31
@oli-obk
Copy link
Contributor

oli-obk commented Feb 15, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Feb 16, 2022

⌛ Testing commit db019f2 with merge a240ccd...

@bors
Copy link
Contributor

bors commented Feb 16, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing a240ccd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 16, 2022
@bors bors merged commit a240ccd into rust-lang:master Feb 16, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 16, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a240ccd): comparison url.

Summary: This benchmark run did not return any relevant results. 11 results were found to be statistically significant but too small to be relevant.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Feb 21, 2022
…ir-val, r=oli-obk"

This reverts commit a240ccd, reversing
changes made to 393fdc1.

This PR was likely responsible for a relatively large regression in
dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours,
bringing that builder into the pool of the slowest builders we currently have.

This seems to be limited to the alt builder due to needing parallel-compiler
enabled, likely leading to slow LLVM compilation for some reason.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2022
Revert rust-lang#93800, fixing CI time regression

This reverts commit a240ccd (merge commit of rust-lang#93800), reversing
changes made to 393fdc1.

This PR was likely responsible for a relatively large regression in
dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours,
bringing that builder into the pool of the slowest builders we currently have.

This seems to be limited to the alt builder due to needing parallel-compiler
enabled, likely leading to slow LLVM compilation for some reason. See some
investigation in [this Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/msvc.28.3F.29.20builders.20running.20much.20slower).

cc `@lcnr` `@oli-obk` `@b-naber` (per original PRs review/author)

We can re-apply this PR once the regression is fixed, but it is sufficiently large that I don't think keeping this on master is viable in the meantime unless there's a very strong case to be made for it. Alternatively, we can disable that builder (it's not critical since it's an alt build), but that obviously carries its own costs.
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this pull request Feb 25, 2022
…r=oli-obk

Treat static refs as `mir::ConstantKind::Val`

With the upcoming introduction of Valtrees we want to treat more values as `mir::ConstantKind::Val` directly.

r? `@lcnr`

cc `@oli-obk`
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-12 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Some tests failed in compiletest suite=mir-opt mode=mir-opt host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
..................................i................................
failures:

---- [mir-opt] mir-opt/const-promotion-extern-static.rs stdout ----
1 - // MIR for `BAR` before PromoteTemps
2 + // MIR for `BAR` after PromoteTemps
+   
+   
4   static mut BAR: *const &i32 = {
5       let mut _0: *const &i32;             // return place in scope 0 at $DIR/const-promotion-extern-static.rs:9:17: 9:28
6       let mut _1: &[&i32];                 // in scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44

9       let mut _4: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
10       let _5: &i32;                        // in scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
11 +     let mut _6: &[&i32; 1];              // in scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44
+   
13       bb0: {
13       bb0: {
14           StorageLive(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44
15           StorageLive(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44

35                                            // + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42
36                                            // + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }
- 
+   
39       bb1: {
39       bb1: {
40 -         StorageDead(_5);                 // scope 0 at $DIR/const-promotion-extern-static.rs:9:43: 9:44
41 -         StorageDead(_3);                 // scope 0 at $DIR/const-promotion-extern-static.rs:9:43: 9:44

42           StorageDead(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:9:43: 9:44
43           return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:9:1: 9:45
- 
+   
+   
46       bb2 (cleanup): {
47           resume;                          // scope 0 at $DIR/const-promotion-extern-static.rs:9:1: 9:45

49 - }
- -
+ - 
+ - 
51 - alloc1 (static: Y, size: 4, align: 4) {
52 -     2a 00 00 00                                     │ *...

- 
+   
55 
55 

thread '[mir-opt] mir-opt/const-promotion-extern-static.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff', src/tools/compiletest/src/runtest.rs:3386:25


failures:
    [mir-opt] mir-opt/const-promotion-extern-static.rs

@b-naber b-naber mentioned this pull request Mar 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2022
Reinstate rust-lang#93800

rust-lang#93800 caused a regression in an alt builder with parallel enabled. rust-lang#94205 reverted that PR because of the regression. For an unknown reason the regression has disappeared, so we reinstate the changes in rust-lang#93800 here.

r? `@Mark-Simulacrum`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2022
…li-obk

Use mir constant in thir instead of ty::Const

This is blocked on rust-lang#94059 (does include its changes, the first two commits in this PR correspond to those changes) and rust-lang#93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Apr 21, 2022
Use mir constant in thir instead of ty::Const

This is blocked on rust-lang/rust#94059 (does include its changes, the first two commits in this PR correspond to those changes) and rust-lang/rust#93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
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.

8 participants