[5.9] AliasAnalysis: add complexity limits to some basic utility functions #68327
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.
Explanation: This fixes a compile time problem which shows up for large nested arrays. The underlying problem is a quadratic complexity in the ARCSequenceOpts. The fix (or workaround) is to add a complexity limit in one of the three AliasAnalysis basic utility functions (which traverse the def-use graph). We already added this kind of complexity limit in the first utility functions some time ago (and this is already in 5.9). This PR contains two commits which each add the complexity limit to one of the two other functions. The first commit was already merged to main some time ago, but unfortunately not cherry-picked to 5.9. The second commit fixes the new problem and depends on the first commit. Therefore it's required and makes sense to cherry-pick both commits.
Issue: rdar://114352817
Risk: Low. The change makes some optimizations more conservative and this only happens in very rare cases.
Testing: With a regression test.
Reviewer: @atrick
Main branch PR: 29246fd of Optimizer: re-implement the RedundantLoadElimination pass in Swift #67395 and AliasAnalysis: use a complexity limit for the isObjReleased function #68316