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

NRVO: Allow occurrences of the return place in var debug info #76306

Merged
merged 1 commit into from
Sep 13, 2020

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Sep 4, 2020

The non-use occurrence of the return place in var debug info does not
currently inhibit NRVO optimization, but it will fail assertion in
visit_place when optimization is performed.

Relax assertion check to allow the return place in var debug info.

This case might be impossible to hit in optimization pipelines as of
now, but can be encountered in customized mir-opt-level=2 pipeline with
copy propagation disabled. For example in:

pub fn b(s: String) -> String {
    a(s)
}

#[inline]
pub fn a(s: String) -> String {
    let x = s;
    let y = x;
    y
}

The non-use occurrence of the return place in var debug info does not
currently inhibit NRVO optimization, but it will fail assertion in
`visit_place` when optimization is performed.

Relax assertion check to allow the return place in var debug info.

This case might be impossible to hit in optimization pipelines as of
now, but can be encountered in customized mir-opt-level=2 pipeline with
copy propagation disabled. For example in:

```
pub fn b(s: String) -> String {
    a(s)
}

#[inline]
pub fn a(s: String) -> String {
    let x = s;
    let y = x;
    y
}
```
@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2020
@jyn514 jyn514 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 4, 2020
@tmiasko
Copy link
Contributor Author

tmiasko commented Sep 5, 2020

r? @ecstatic-morse

@ecstatic-morse
Copy link
Contributor

Sorry. I seem to have missed this one. This will cause any VarDebugInfo for the old return place to be merged with VarDebugInfo for the new one. AFAICT, the only alternative would be to delete VarDebugInfo for the old return place before replacing it. Is there a reason to prefer one to the other?

@tmiasko
Copy link
Contributor Author

tmiasko commented Sep 12, 2020

Mapping different user variables to the same place is perfectly fine and makes user variables accessible from a debugger, so that option is definitely preferable.

@ecstatic-morse
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 12, 2020

📌 Commit 0151061 has been approved by ecstatic-morse

@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 Sep 12, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 12, 2020
…morse

NRVO: Allow occurrences of the return place in var debug info

The non-use occurrence of the return place in var debug info does not
currently inhibit NRVO optimization, but it will fail assertion in
`visit_place` when optimization is performed.

Relax assertion check to allow the return place in var debug info.

This case might be impossible to hit in optimization pipelines as of
now, but can be encountered in customized mir-opt-level=2 pipeline with
copy propagation disabled. For example in:

```rust
pub fn b(s: String) -> String {
    a(s)
}

#[inline]
pub fn a(s: String) -> String {
    let x = s;
    let y = x;
    y
}
```
@bors
Copy link
Contributor

bors commented Sep 13, 2020

⌛ Testing commit 0151061 with merge 498dab0...

@bors
Copy link
Contributor

bors commented Sep 13, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: ecstatic-morse
Pushing 498dab0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 13, 2020
@bors bors merged commit 498dab0 into rust-lang:master Sep 13, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 13, 2020
@tmiasko tmiasko deleted the nrvo-debuginfo branch September 13, 2020 07:39
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.

7 participants