-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[mandatory-combine] Add a canonicalization impl and prepare to use mandatory-combine to test ownership RAUW code #34968
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
[mandatory-combine] Add a canonicalization impl and prepare to use mandatory-combine to test ownership RAUW code #34968
Conversation
@swift-ci test |
preset=buildbot,tools=RA,stdlib=RD,test=non_executable |
Build failed |
Build failed |
@swift-ci benchmark |
The failure of macOS platform non-executable is known: https://ci.swift.org/job/oss-swift_tools-RA_stdlib-DA_test-device-non_executable/289/console |
@swift-ci benchmark |
@swift-ci test OS X platform |
Looked at the Linux runtime failures. What is happening here is that they are testing non-uniqueness by just creating a local variable and we are cleaning it up = p. I am going to change the test to store into a global. That will be preserved and ensure non-uniqueness. |
…on while performing mandatory combining.
…y when compiling with opts. When originally made, the thought behind mandatory combine was that at -Onone, we are at the end of the pipeline so we are going to be destroying our module anyways, so there is no reason to delete dead instructions. We are also running it at -O, -Osize, so why not eliminate these instructions when we prepare for sil optimizations! So I put in some conditional code that causes us to delete trivial instructions as we set up our worklist and if one pops off the worklist during traversal. The reason why I am doing this is that I realized that I do not want to use SILGenCleanup to test InstSimplify code. In fact, I do not want any of my RAUW code to be emitted by SILGenCleanup since I don't want to disturb the codegen of the early passes so I don't have to update a bunch of tests = (. So instead, I am going to use mandatory combine for this purpose and doing this cleans up the tests a little bit. It also will just eliminate a bunch of early unnecessary code as well.
…ipKind::None are trivially dead, so make isInstructionTriviallyDead return true for those cases!
915c7a2
to
c6525fd
Compare
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibsHow to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci benchmark |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibsHow to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
Build failed |
@swift-ci test |
If I can't figure out quickly where the divergence in these results are coming from, I am just going to enable this thing behind an option and then loop back around. I need this for testing purposes I don't care if in the short term this changes do not run in the pipeline. |
Build failed |
Build failed |
Changed my mind. Going to do this behind a flag for now so I can do my testing and not change code-gen. |
I am going to put this behind an option and use this for tests. In the future I am going to loop back around on this and see what is going on. |
…g so I can use it for writing OSSA RAUW tests. I am going to loop back around and enable this all the time, but this is seeming to disturb codegen more than expected, so I am going to enable it everywhere later (since it is not my primary goal).
@swift-ci benchmark |
@@ -156,6 +214,12 @@ void MandatoryCombiner::addReachableCodeToWorklist(SILFunction &function) { | |||
++iterator; | |||
|
|||
if (isInstructionTriviallyDead(instruction)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already "doing the work" in Onone. We should either just erase the known-dead instruction, or not call isInstructionTriviallyDead
at all (preferably the later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to know to skip it. We are keeping the size of the worklist down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
@@ -75,6 +75,12 @@ sil @myint_from_myint_and_proto : $@convention(thin) (MyInt, @guaranteed { var P | |||
|
|||
sil @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt | |||
|
|||
// Optional support | |||
enum FakeOptional<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this declaration isn't actually used in the test...?
It would be good to test a Swift program that uses this type, though. That's where we've run into problems with this optimization in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just misc boiler plate tests that I add in most tests. Its useful to have.
@@ -156,6 +214,12 @@ void MandatoryCombiner::addReachableCodeToWorklist(SILFunction &function) { | |||
++iterator; | |||
|
|||
if (isInstructionTriviallyDead(instruction)) { | |||
if (EnableCanonicalizationAndTrivialDCE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these be flattened into one if
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something that is meant to be deleted soon. I think it is fine given that this is temporary. I need this for testing purposes for something else.
@gottesmm just FYI I made a similar change to remove dead instructions in #30429. It was then reverted (in #31077) because of a bug with enums. I have a fix for that enum bug in #31779 and plan to re-land that patch once the enum thing is fixed. This is behind a flag so it should be fine, but maybe still good to run a full source compatibility test. |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@zoecarver I think I may have fixed that issue with my ArgumentScope change. |
@swift-ci smoke test |
Thanks. I'll see if the tests pass on main. |
This PR contains a few changes I need to make to mandatory combiner so I can use it to test my ownership RAUW code. Specifically: