Skip to content

Fix register allocation in the presence of singled-valued phi nodes #7281

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

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented May 24, 2023

With optimizations disabled, the register allocator in beam_ssa_pre_codegen could allocate different variables to the same register if single-valued phi nodes in a try/catch construct were present.

Closes #7248

@bjorng bjorng added team:VM Assigned to OTP team VM fix labels May 24, 2023
@bjorng bjorng requested a review from jhogberg May 24, 2023 07:25
@bjorng bjorng self-assigned this May 24, 2023
@bjorng bjorng linked an issue May 24, 2023 that may be closed by this pull request
@bjorng bjorng added the testing currently being tested, tag is used by OTP internal CI label May 24, 2023
Copy link
Contributor

@RobinMorisset RobinMorisset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bjorng bjorng force-pushed the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch from 3321efc to 97515c1 Compare May 24, 2023 07:37
@github-actions
Copy link
Contributor

github-actions bot commented May 24, 2023

CT Test Results

       2 files     296 suites   12m 29s ⏱️
   777 tests    775 ✔️ 2 💤 0
4 913 runs  4 911 ✔️ 2 💤 0

Results for commit 3cb4455.

♻️ 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

@RobinMorisset
Copy link
Contributor

This PR makes the following erlang test cases:

f(_V0) ->
    {_V0 and _V0, [ok || <<_:(_V0)/integer-unsigned>> <= port_to_list(_V0 orelse _V0)]}.

and

f(_V1) when (_V1 xor _V1); {_V1} ->
    erlang:insert_element(_V1 orelse _V1, ok, ok),
    _V1.

and

f(_V1) ->
    case ok of
        _ ->
            not _V1,
            [ok || _ := <<_:(_V1)/bytes>> <- (_V1 andalso _V1)]
    end.

fail to compile with variations of the following error message:

Internal consistency check failed - please report this bug.
  Instruction: {swap,{y,1},{x,0}}
  Error:       {uninitialized_reg,{y,1}}:

I can provide more test cases if it would be useful for debugging.

@bjorng bjorng force-pushed the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch from 97515c1 to 0ff39ca Compare May 26, 2023 11:51
@bjorng
Copy link
Contributor Author

bjorng commented May 26, 2023

I have now pushed a different solution that I hope has no undesirable side effects.

With optimizations disabled, the register allocator in
`beam_ssa_pre_codegen` could allocate different variables to the
same register if single-valued phi nodes in a try/catch construct
were present.

Closes erlang#7248
@bjorng bjorng force-pushed the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch from 0ff39ca to 3cb4455 Compare May 26, 2023 13:44
@bjorng bjorng merged commit fa2499d into erlang:maint May 30, 2023
@bjorng bjorng deleted the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch May 30, 2023 07:50
@bjorng bjorng restored the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch May 30, 2023 11:09
@bjorng bjorng deleted the bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600 branch June 9, 2023 05:02
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] miscompilation with optimizations turned off
2 participants