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

Substitute types before checking inlining compatibility. #113802

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jul 17, 2023

Addresses #112332 and #113781

I don't have a minimal test, but I this seems to remove the ICE locally.

This whole pre-inlining validation mirrors the "real" MIR validation pass to verify that inlined MIR will still pass validation.
The debuginfo loop is added because MIR validation check projections in debuginfo.
Likewise, MIR validation only checks is_subtype, so there is no reason for a stronger check.

The types were not being substituted in check_equal, so we were not bailing out of inlining if the substituted MIR callee body would not pass validation.

@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@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 Jul 17, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@cjgillot cjgillot changed the title Substitute types before checking compatibility. Substitute types before checking inlining compatibility. Jul 17, 2023
@cjgillot cjgillot added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Jul 17, 2023
@@ -440,6 +440,10 @@ impl<'tcx> Inliner<'tcx> {
validation: Ok(()),
};

for var_debug_info in callee_body.var_debug_info.iter() {
Copy link
Member

Choose a reason for hiding this comment

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

What's this for?

Copy link
Member

Choose a reason for hiding this comment

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

(answered in: #113802 (comment) )

if ty == f_ty {
return;
}
if !util::is_subtype(this.tcx, this.param_env, ty, f_ty) {
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, but why are we changing this from is_equal_up_to_subtyping? I guess do we only want to check that ty <: f_ty?

Copy link
Member

Choose a reason for hiding this comment

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

(answered in: #113802 (comment) )

@cjgillot
Copy link
Contributor Author

I should have put more context in the PR comment.
This whole pre-inlining validation mirrors the "real" MIR validation pass to verify that inlined MIR will still pass validation.
The debuginfo loop is added because MIR validation check projections in debuginfo.
Likewise, MIR validation only checks is_subtype, so there is no reason for a stronger check.

This ad-hoc validation should reuse the existing MIR validation code, and not brew its own, but that's for another PR.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 20, 2023

📌 Commit 45ffe41 has been approved by compiler-errors

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 20, 2023
@cjgillot cjgillot added beta-nominated Nominated for backporting to the compiler in the beta channel. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Jul 20, 2023
@cjgillot
Copy link
Contributor Author

I'm nominating for backport, as both ICEs affect stable 1.71.0.

@bors
Copy link
Contributor

bors commented Jul 21, 2023

⌛ Testing commit 45ffe41 with merge 6b29036...

@bors
Copy link
Contributor

bors commented Jul 21, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 6b29036 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 21, 2023
@bors bors merged commit 6b29036 into rust-lang:master Jul 21, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 21, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6b29036): 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

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)
-3.6% [-3.6%, -3.6%] 1
Improvements ✅
(secondary)
-2.9% [-3.0%, -2.7%] 2
All ❌✅ (primary) -3.6% [-3.6%, -3.6%] 1

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

Binary size

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

Bootstrap: 651.291s -> 649.721s (-0.24%)

@cjgillot cjgillot deleted the check-debuginfo branch July 21, 2023 13:54
@apiraino
Copy link
Contributor

Beta + stable backports approved as per compiler team on Zulip

@rustbot label +beta-accepted +stable-accepted

@rustbot rustbot added beta-accepted Accepted for backporting to the compiler in the beta channel. stable-accepted Accepted for backporting to the compiler in the stable channel. labels Jul 28, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2023
Prepare Rust 1.71.1

This PR prepares the Rust 1.71.1 release, which contains:

* rust-lang#113802
* rust-lang#113579
* rust-lang#111516
* rust-lang#112517
* rust-lang@67b5990 (from rust-lang#113678)

r? `@ghost`
cc `@rust-lang/release`
@cuviper cuviper mentioned this pull request Aug 12, 2023
@cuviper cuviper modified the milestones: 1.73.0, 1.72.0 Aug 12, 2023
@cuviper cuviper removed beta-nominated Nominated for backporting to the compiler in the beta channel. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Aug 12, 2023
@cuviper cuviper modified the milestones: 1.72.0, 1.71.1 Aug 12, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 12, 2023
[beta] backport

* Restrict linker version script of proc-macro crates to just its two symbols rust-lang#114470
* bootstrap: config: fix version comparison bug rust-lang#114440
* lint/ctypes: only try normalize rust-lang#113921
* Avoid tls access while iterating through mpsc thread entries rust-lang#113861
* Substitute types before checking inlining compatibility. rust-lang#113802
* Revert "fix: bug etc/bash_complettion -> src/etc/... to avoid copy error" rust-lang#113579
* lint/ctypes: fix () return type checks rust-lang#113457
* Rename and allow cast_ref_to_mut lint rust-lang#113422
* Ignore flaky clippy tests. rust-lang#113621

r? cuviper
if ty == f_ty {
return;
}
if !util::is_subtype(this.tcx, this.param_env, ty, f_ty) {
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to add a comment pointing to the issue(s), to give some context to this check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining beta-accepted Accepted for backporting to the compiler in the beta channel. 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. stable-accepted Accepted for backporting to the compiler in the stable channel. 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