-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Move mandatory inlining cleanup to mandatory combine #28396
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
Move mandatory inlining cleanup to mandatory combine #28396
Conversation
This is the wrong way to do this. What we want to do is move stuff into the mandatory combiner since it runs after diagnostics. That way we can make it easy for SourceKit to not run this sort of code. |
I re-wrote this patch fixing most of the issues that you brought up. I removed changes to The basic flow of this pass is now:
The recursive inlining is now removed. All mandatory inlining tests pass (assuming I ran the right tests). There are still a few things I want to clean up (see TODOs). I'll probably fix those in a different patch, though. |
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.
Some initial comments. I want to read this code in more detail before it lands.
|
||
// First collect all the applies | ||
SmallVector<FullApplySite, 12> applyInsts; | ||
while (SILBasicBlock *block = domOrder.getNext()) { |
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.
Why do you need to use the dominator info here?
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 don't. I'll remove it.
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.
Hmm. To be honest, I'm not quite sure why reading the blocks in dominance order fixes this, but, when inlining an auto closure with -enable-ownership-stripping-after-serialization
, the verifier fails because convert_escape_to_noescape [not_guaranteed] not allowed after mandatory passes
. Using dominance order fixes that.
Edit: see test_chained_short_circuit
for example.
@@ -665,6 +667,7 @@ SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) { | |||
SILPassPipelinePlan P(Options); | |||
|
|||
P.startPipeline("Mandatory Combines"); | |||
P.addMandatoryInlining(); |
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 should not be necessary. Please remove this.
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.
testOriginalProtocolImpl
doesn't inline cFuncOriginal
in mandatory_conditional_compile_out_using_optionals.swift
(among others) when this pass isn't run for Onone
.
So I was thinking about this a little bit. We need to do this differently/split this up. Here is my suggestion:
|
@gottesmm, that sounds good to me. I'll look into making a cleanup patch. I'm not 100% sure the cleanup done here is necessary, though. I think the mandatory combiner might already handle this. I'll double-check and make a patch if not. I would also be interested to learn more about the pass manager. Feel free to reach out to me whenever (no rush, though, I'm sure you're busy). |
Closing for now. Might reopen later. |
This patch makes
MandatoryInlining
aSILModuleTransform
instead of aSILFunctionTransform
. It also moves the function removal cleanup toMandatoryCombine
so that it will be run on every function. This is better because then we don't have to iterate over every function in a module twice inMandatoryInlining
. And now, both can remain aSILFunctionTransform
. It also has the benefit of allowingMandatoryCombine
to exit early sometimes.The successor to #28394.
cc @gottesmm