Ensure stdlib parses again after #79186. #79567
Draft
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
That pr converted PredictableMemoryAccessOptimizations function pass to Swift. Both versions of this pass remove unreachable terminators at the end of apparent infinite loops that are guaranteed to eventually return. The stdlib has a number of instances where apparent infinite loops are used.
When Swift host tools are available, so are the Swift function passes, and these unreachable terminators are removed as before. However, when the host tools are not available (e.g., using a configuration like the stdlib and we get a dataflow error manifesting as a "missing return".
To extricate ourselves out of this situation, we have a few options.
One option is determining that #79186 marks the end of the road for the compiler to be bootstrapped from C++. However, that is somewhat unsatisfying, since there is a great reticence to accepting maintenance patches on previous compiler branches and leaves questions about how an older version of the "bootstrap" compiler should be kept up-to-date, since presumably as new platforms come online to bootstrap Swift, code changes to C++ would still be warranted.
Alternatively, there is already a stated goal that the C++ compiler should not necessarily emit the most optimized code, and that the compiler built with Swift host tools would emit better optimized code. In this case, we would want to add an additional pass for the bootstrap compiler to just detect the apparent infinite loop case and make sure no errors occur. This is probably the correct thing to do, however, it is probably a slightly nontrivial undertaking.
In the meantime, we need to ensure we can continue to bootstrap with the spot where the "missing return" error happens. This is not exactly the cleanest solution, but it does ensure the build is fixed again in this configuration.
(Because this is not perhaps the best solution to address this problem, I've made this a draft pr instead, so at least this unblocks builds.)