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

Fix insertion of statements to be executed along return edge in inlining #117783

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Nov 10, 2023

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes #117355

@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2023

r? @davidtwco

(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 Nov 10, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@cjgillot
Copy link
Contributor

@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 Nov 14, 2023
@bors
Copy link
Contributor

bors commented Nov 14, 2023

⌛ Trying commit d2ed699 with merge af26da3...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 14, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
};

let return_block = if let Some(block) = target {
// Prepare a new block for code that should execute when call returns. We don't use
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we attempt to avoid creating this new block if target has only a single predecessor? I started perf to verify whether there is anything to gain.

@bors
Copy link
Contributor

bors commented Nov 14, 2023

☀️ Try build successful - checks-actions
Build commit: af26da3 (af26da3cf9059da2b7aa0ac5641421a2d641b9c0)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (af26da3): comparison URL.

Overall result: no relevant changes - 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 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.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [0.8%, 0.8%] 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)
- - 0
Improvements ✅
(primary)
-0.5% [-0.5%, -0.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.5% [-0.5%, -0.5%] 1

Binary size

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

Bootstrap: 674.708s -> 673.584s (-0.17%)
Artifact size: 311.11 MiB -> 311.12 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 14, 2023
@davidtwco davidtwco assigned cjgillot and unassigned davidtwco Nov 19, 2023
@cjgillot
Copy link
Contributor

Apparently no perf to gain.
@bors r+

@bors
Copy link
Contributor

bors commented Nov 19, 2023

📌 Commit d2ed699 has been approved by cjgillot

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 Nov 19, 2023
@bors
Copy link
Contributor

bors commented Nov 19, 2023

⌛ Testing commit d2ed699 with merge 1aa6312...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 19, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 19, 2023
@cjgillot cjgillot 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 19, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 19, 2023

  • Upgraded test case to a new custom MIR call syntax.

@rustbot ready

@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 Nov 19, 2023
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 20, 2023

📌 Commit 1acecda has been approved by cjgillot

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 Nov 20, 2023
@bors
Copy link
Contributor

bors commented Nov 20, 2023

⌛ Testing commit 1acecda with merge db9e655...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 20, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 20, 2023
Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 20, 2023

  • Updated test output for panic-abort (wasm32-unknown-unknown target).

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Nov 20, 2023

📌 Commit 1be1c2e has been approved by cjgillot

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 Nov 20, 2023
@bors
Copy link
Contributor

bors commented Nov 20, 2023

⌛ Testing commit 1be1c2e with merge 79e961f...

@bors
Copy link
Contributor

bors commented Nov 20, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 79e961f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 20, 2023
@bors bors merged commit 79e961f into rust-lang:master Nov 20, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 20, 2023
@tmiasko tmiasko deleted the inline-ret branch November 20, 2023 12:17
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (79e961f): 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)
4.6% [4.6%, 4.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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

Bootstrap: 677.224s -> 674.774s (-0.36%)
Artifact size: 313.73 MiB -> 313.77 MiB (0.01%)

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.

MIR validation error at mir-opt-level>=3
7 participants