8000 Avoid optimization that beam_validator might consider unsafe by bjorng · Pull Request #7330 · erlang/otp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Avoid optimization that beam_validator might consider unsafe #7330

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 2 commits into from
Jun 1, 2023

Conversation

bjorng
Copy link
Contributor
@bjorng bjorng commented May 31, 2023

Eliminating a repeated =:= test can result in code that beam_validator doesn't consider safe. This pull request makes the optimization keep =:= if it seems to be significant, that is, if one or both operands will gain type information from it.

That makes it possible to compile code from #6599 such as:

    f(X, X) when is_integer(X) ->
        ok;
    f(Y, Y = #{}) ->
        Y#{ok := ok}.

(Six other examples from #6599 can now also be compiled.)

Running scripts/diffable shows that this fix prevented the optimization in 14 modules (out of about 1000).

Closes #6599 (the examples that were not fixed by this PR will be transferred to a new issue)

bjorng added 2 commits May 31, 2023 12:42
Eliminating a repeated `=:=` test can result in code that
beam_validator doesn't consider safe. This commit makes the optimization
keep the `=:=` if it seems to be significant, that is, if one or both
operands will gain type information from it.

That makes it possible to compile code from erlang#6599 such as:

    f(X, X) when is_integer(X) ->
        ok;
    f(Y, Y = #{}) ->
        Y#{ok := ok}.

(Six other examples from erlang#6599 can now also be compiled.)

Running `scripts/diffable` shows that this fix prevented the
optimization in 14 modules (out of about 1000).

Closes erlang#6599
@bjorng bjorng added team:VM Assigned to OTP team VM fix testing currently being tested, tag is used by OTP internal CI labels May 31, 2023
@bjorng bjorng requested a review from jhogberg May 31, 2023 10:52
@bjorng bjorng self-assigned this May 31, 2023
@github-actions
Copy link
Contributor
github-actions bot commented May 31, 2023

CT Test Results

       2 files     296 suites   22m 40s ⏱️
   777 tests    774 ✔️ 2 💤 1
4 921 runs  4 918 ✔️ 2 💤 1

For more details on these failures, see this check.

Results for commit a99d48f.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@bjorng bjorng force-pushed the bjorn/compiler/partially-solve-gh-6599 branch from a99d48f to 5896312 Compare June 1, 2023 13:23
@bjorng bjorng merged commit a388a6d into erlang:master Jun 1, 2023
@bjorng bjorng deleted the bjorn/compiler/partially-solve-gh-6599 branch June 1, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[erlc] internal consistency check failed: "illegal_branch, try_handler"
3 participants
0