Skip to content

Do not emit shadow copied for inout parameters #5218

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

Merged
merged 41 commits into from
Oct 13, 2016

Conversation

shajrawi
Copy link

@shajrawi shajrawi commented Oct 11, 2016

radar rdar://problem/28434323

SILGen has no reason to insert shadow copies for inout parameters any more. They cannot be captured. We still emit these copies. Sometimes deshadowing removes them, but sometimes it does not.

In this PR we just avoid emitting the copies and remove the deshadowing pass.

This PR chery-picked some of @dduan work and built on top of it.

@shajrawi
Copy link
Author

@atrick Can you please review?

@shajrawi
Copy link
Author

@swift-ci Please smoke test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Can you identify some unit tests that handle captured inout, and are you convinced they do the right thing? Can you add a test from the bug report to verify that local functions capturing inout are now handled the same as anonymous closures?

Otherwise this looks fine to me.

@@ -262,19 +262,10 @@ struct ArgumentInitHelper {
gen.B.createDebugValueAddr(loc, address, {vd->isLet(), ArgNo});
return;
}
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(argrv.getValue());
assert(argrv.getType().isAddress() && "expected inout to be address");
gen.B.createDebugValueAddr(loc, argrv.getValue(), {vd->isLet(), ArgNo});
Copy link
Contributor

Choose a reason for hiding this comment

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

The BuiltinUnsafeValueBufferType case above passes the unmanaged address to DebugValueAddr. This new default case passes a the argv value directly to DebugValueAddr. Why is there any difference?

Copy link
Author

Choose a reason for hiding this comment

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

Combined debug value creation + added unit tests as requested.

@lattner
Copy link
Contributor

lattner commented Oct 11, 2016

Awesome, thank you for working on this Joe, I look forward to this all getting cleaner and simpler.

@shajrawi
Copy link
Author

@swift-ci Please smoke test

@shajrawi
Copy link
Author

Linux smoke test failing with the usual non-PR related error - rerunning:
/home/buildnode/disk2/workspace/swift-PR-Linux-smoke-test/branch-master/swiftpm/Tests/XcodeprojTests/XcodeProjectModelTests.swift:12:8: error: module file was created by an older version of the compiler; rebuild 'TestSupport' and try again: /home/buildnode/disk2/workspace/swift-PR-Linux-smoke-test/branch-master/buildbot_linux/swiftpm-linux-x86_64/debug/TestSupport.swiftmodule

@shajrawi
Copy link
Author

@swift-ci Please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Oct 11, 2016

Before this is merged, could you please squash @dduan's commits?

@dduan
Copy link
Contributor

dduan commented Oct 11, 2016

Yes please squash...these were never meant to be public :)

@shajrawi
Copy link
Author

I intended to auto-squash everything into one commit on merge - all commits are about the same thing :)

@shajrawi shajrawi merged commit 91bba4d into swiftlang:master Oct 13, 2016
@shajrawi shajrawi deleted the inout_shadow_escaping_closure branch October 13, 2016 17:11
@swiftix
Copy link
Contributor

swiftix commented Oct 13, 2016

@shajrawi Have you forgotten to squash the commits?

@shajrawi
Copy link
Author

@swiftix I squashed it - it is a single commit on mainline, no? (I clicked squash and merge In the PR)

@swiftix
Copy link
Contributor

swiftix commented Oct 13, 2016

@shajrawi Ah, OK. I assumed you'd squash and push --force on the PR first and then merge. This is the usual way to it, because then the PR looks the same as the final merged set of commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants