Skip to content

[SILOptimizer] Added MandatoryCombiner. #26913

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 1 commit into from
Aug 29, 2019

Conversation

nate-chandler
Copy link
Contributor

Minimal commit to get the mandatory combiner rolling. At the moment, the mandatory combiner only processes partial apply instructions, attempting both to replace their applies with applies of their underlying function refs and also to eliminate them altogether. That processing is only done if all the arguments to the apply and to the partial apply are trivial.

For now, the pass is not part of any pipeline.

@nate-chandler nate-chandler requested a review from gottesmm August 28, 2019 19:38
@nate-chandler
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

Some initial comments. My brain is a little off today, so I need to read the loop optimization in more detail.

One other thing. Can you add ossa versions of this test? It generally isn't too difficult to convert. I can show you how to do it if you want.

@nate-chandler nate-chandler force-pushed the mandatory-combiner branch 2 times, most recently from f0c28d3 to 1a506b4 Compare August 28, 2019 21:21
@gottesmm
Copy link
Contributor

I just realized for a second a bit of your confusion. When I said the "loop optimization", I meant the iterators.

@nate-chandler nate-chandler force-pushed the mandatory-combiner branch 4 times, most recently from d73de89 to 14595c0 Compare August 28, 2019 23:09
@nate-chandler
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci Please smoke test

@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test

@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test linux

@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test

// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should establish the practice of adding file-level comments to new passes. What is the intention of the pass? Where is it expected and/or valid to run in the pipeline? Does it need to run before diagnostics? Or is it an optional Onone optimization? What are the pass dependencies--can other passes interfere with this, or is this helpful to run before certain passes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would something like this be?

///
///  \file
///  Defines the MandatoryCombiner function transform.  The pass contains basic
///  instruction combines to be performed at the begining of both the Onone and
///  also the performance pass pipelines, after the diagnostics passes have been
///  run.  It is intended to be run before and to be independent of other
///  transforms.
///
//===----------------------------------------------------------------------===//

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put a newline after \file.

Also can you put in some prose that says something along the lines of: "The intention of this pass is to be a place for mandatory peepholes that are not needed for diagnostics. Please put any such peepholes here instead of in the diagnostic passes".

@@ -312,6 +312,8 @@ PASS(SerializeSILPass, "serialize-sil",
PASS(YieldOnceCheck, "yield-once-check",
"Check correct usage of yields in yield-once coroutines")
PASS(OSLogOptimization, "os-log-optimization", "Optimize os log calls")
PASS(MandatoryCombiner, "mandatory-combiner",
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that there is a new line at the end of this line. Did you run this code through git-clang-format? (TBH, I forgot if git-clang-format handles .def files, but I think it does). If you did and my memory is wrong, can you get rid of the newline?

If you don't know how to setup git-clang-format/etc I can show you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea git-clang-format doesn't touch the .def. It does find some things though to fix. When I locally read your code and run git-clang-format on this I see:

diff --git a/lib/SILOptimizer/Mandatory/MandatoryCombiner.cpp b/lib/SILOptimizer/Mandatory/MandatoryCombiner.cpp
index feffce765ae..6c916b28d43 100644
--- a/lib/SILOptimizer/Mandatory/MandatoryCombiner.cpp
+++ b/lib/SILOptimizer/Mandatory/MandatoryCombiner.cpp
@@ -22,7 +22,7 @@
 
 using namespace swift;
 
-/// \returns whether all the values are of trivial type in the provided 
+/// \returns whether all the values are of trivial type in the provided
 ///          function.
 template <typename Values>
 static bool areAllValuesTrivial(Values values, SILFunction &function) {
@@ -159,7 +159,6 @@ struct MandatoryCombiner : SILFunctionTransform {
     }
   }
 };
-
 } // end anonymous namespace
 
 SILTransform *swift::createMandatoryCombiner() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Getting rid of the newline results in a line with 84 characters. Is that desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whitespace is fixed.

@nate-chandler nate-chandler force-pushed the mandatory-combiner branch 2 times, most recently from c084d38 to befe56f Compare August 29, 2019 19:18
@nate-chandler
Copy link
Contributor Author

@swift-ci smoke test

@nate-chandler
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please smoke test

@gottesmm
Copy link
Contributor

Nice. This LGTM.

Minimal commit to get the mandatory combiner rolling.  At the moment,
the mandatory combiner only processes partial apply instructions,
attempting both to replace their applies with applies of their
underlying function refs and also to eliminate them altogether.  That
processing is only done if all the arguments to the apply and to the
partial apply are trivial.

For now, the pass is not part of any pipeline.
@nate-chandler
Copy link
Contributor Author

@swift-ci please smoke test and merge

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit bd222ad into swiftlang:master Aug 29, 2019
@nate-chandler nate-chandler deleted the mandatory-combiner branch July 5, 2023 23:32
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.

4 participants