compiler: Fix alias analysis bug (less conservative version of #9833) #9834
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.
Previously all bifs selected by the erl_internal:comp_op/2 predicate was erroneously considered safe from an aliasing perspective. This is not true as they, depending on the argument types, could access internal elements of a term which has been destructively updated. As this makes the destructive update visible, this is illegal and should not happen.
To fix this problem, we have to consider all comparison bifs as aliasing operations, thus avoiding the problem described above. Unfortunately this is a very pessimistic solution, and by making use of type information we can avoid forced aliasing when it can be determined that the comparison bif will be reduced to a simple tag test.
This is less conservative fix than the one presented in #9833.
Closes #9813.