Skip to content

Cleanup/fix AccessEnforcementOpts #23190

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 10 commits into from
Mar 20, 2019
Merged

Cleanup/fix AccessEnforcementOpts #23190

merged 10 commits into from
Mar 20, 2019

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Mar 8, 2019

Simplify the analysis and dataflow to make the pass faster eliminate bugs as a side effect.

This is broken into a series of commits. The commit called "Redo the data flow" can't be reviewed as a diff. It's best just to read the new code, referencing the old code if it's helpful.

I'm posting this somewhat prematurely (I haven't done self-review or looked into adding more tests) so there is plenty of time for review. I don't plan on checking in until a week from now.

@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2019

@swift-ci test.

@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2019

@swift-ci test source compatibility.

@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2019

@swift-ci benchmark.

@swift-ci
Copy link
Contributor

swift-ci commented Mar 8, 2019

Build failed
Swift Test OS X Platform
Git Sha - cbedcfe8a628cc291c4895d5e8426930235575bd

@swift-ci
Copy link
Contributor

swift-ci commented Mar 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - cbedcfe8a628cc291c4895d5e8426930235575bd

@swift-ci
Copy link
Contributor

swift-ci commented Mar 8, 2019

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
DataAppendDataLargeToLarge 38200 50600 +32.5% 0.75x (?)

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
RandomShuffle.o 3507 3547 +1.1% 0.99x
Improvement
main.o 57853 56029 -3.2% 1.03x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Improvement
RandomShuffleLCG2 1728 1568 -9.3% 1.10x (?)
ObjectiveCBridgeStubFromNSDateRef 4330 3940 -9.0% 1.10x (?)

Code size: -Osize

TEST OLD NEW DELTA RATIO
Improvement
main.o 54801 52161 -4.8% 1.05x
How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

atrick added 10 commits March 18, 2019 12:42
Most of the API's operate on the data flow state (RegionState) with
respect to the information for a given access (AccessInfo). Calling
them both "info" made the code completely indecipherable.
And remove cubic behavior.
The previous design was customized to perfoming IPO with
GenericSideEffectAnalysis. Expose the underlying logic as a utility so
that AccessEnforcementOpts can use it to summarize loops (in addition
to call sites).
AccessSummary was storing unnecessary state in every per-block entry in the
global map. It was also making most of the code in this pass very hard to read.

Rewriting mergePredAccesses allows AccessSummary to be removed. The
new implementation also avoids unnecessary DenseMap lookups.

There is also a functional change. mergePredAccesses was clearing the
state of predecessor blocks. This isn't logical and had no explanation.
The optimization already proves that there are no potential conflicts
between the two merged scopes, so merging them can't introduce a new
nested conflict.
Directly implement the data flow. Eliminate the extraneous work.
Remove cubic behavior. Do a single iteration of the data flow state at
each program point only performing the necessary set operations. At
unidentified access, clear the sets for simplicity and efficiency.

This cleanup results in significant functional changes:

- Allowing scopes to merge even if they are enclosed.

- Handling unidentified access conservatively.

Note that most of the added lines of code are comments.

Somehow this cleanup incidentally fixes:
<rdar://problem/48514339> swift compiler hangs building project

(I expected the subsequent loop summary cleanup to fix that problem.)
Reuse AccessStorageAnalysis to summarize accesses.

Don't ignore call sites in loops.

Don't consider a read access in a loop to conflict with a read
outside.

Use the unidentified access flag from the analysis.

Remove extraneous code, some of which was unreachable.

General cleanup.
@atrick
Copy link
Contributor Author

atrick commented Mar 19, 2019

@swift-ci test.

@atrick
Copy link
Contributor Author

atrick commented Mar 19, 2019

@swift-ci test source compatibility.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cbedcfe8a628cc291c4895d5e8426930235575bd

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cbedcfe8a628cc291c4895d5e8426930235575bd

@atrick atrick changed the title [WIP] Cleanup/fix AccessEnforcementOpts Cleanup/fix AccessEnforcementOpts Mar 19, 2019
@atrick
Copy link
Contributor Author

atrick commented Mar 20, 2019

@swift-ci test linux platform.

@atrick atrick requested a review from shajrawi March 20, 2019 16:58
Copy link

@shajrawi shajrawi left a comment

Choose a reason for hiding this comment

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

LGTM

@atrick atrick merged commit 71b012e into swiftlang:master Mar 20, 2019
atrick added a commit that referenced this pull request Mar 21, 2019
Merge pull request #23190 from atrick/cleanup-accessopts
@atrick atrick deleted the cleanup-accessopts branch May 8, 2019 21:38
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.

3 participants