-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[erlc] miscompilation with optimizations turned off #7248
Comments
This fixes erlang#7248, but it might not be the best or most elegant fix.
Yes, There is a bug in the register allocator in
Here the values of all three phi nodes end up in the same BEAM register ( This bug it not normally exposed, because there are optimizations that remove assignments to variables that are never used, and there is another optimization that eliminates singled-valued phi nodes. The bug disappears when There are several possible ways to fix this bug. I will do some more thinking before I create a pull request. |
Here is another miscompilation that seems fairly similar: f(_V0) ->
try not (_V3 = (ok >= _V0)) of
_V3 -> iolist_size(maybe
[] ?= _V3,
<<>> ?= list_to_binary(ok)
end);
_ -> ok
after
ok
end.
wrapper0() ->
io:write(catch f(ok)). It prints master...bjorng:otp:bjorn/compiler/beam_ssa_pre_codegen/GH-7248 does not fix it, although it fixes the original testcase. |
And another one: f(_V1) ->
try erlang:bump_reductions(_V1) of
_V3 ->
try not (_V4 = (_V3 andalso is_number(ok))) of
_V4 ->
(_V5 = ok) andalso ok;
_ ->
_V4
catch
_ ->
ok
end
after
ok
end.
wrapper0() ->
io:write(catch f(2147483647)). It prints |
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
Turned out that all single-valued phi nodes are problematic. The linked pull request has a more general solution (which is also simpler) than my previous attempt. |
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
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
…8600' into bjorn/maint/primary_preloaded * bjorn/compiler/beam_ssa_pre_codegen/erlangGH-7248/OTP-18600: Fix register allocation in the presence of singled-valued phi nodes
…gen/GH-7248/OTP-18600 Fix register allocation in the presence of singled-valued phi nodes
…into maint-26 * bjorn/compiler/beam_ssa_pre_codegen/GH-7248/OTP-18600: Fix register allocation in the presence of singled-valued phi nodes
Describe the bug
On the following code:
Running it with the following commands:
results in
8
being printed to the shell. But adding+no_bool_opt +no_ssa_opt
to erlc makes it output0
instead.Expected behavior
I believe that 8 is the valid result:
_
so it is a matchAffected versions
Additional context
The following were tried and make the bug disappear:
The text was updated successfully, but these errors were encountered: