Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-956

Compiler breaking on elixir project due to ssa

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 22.0.1
    • Fix Version/s: 22.0.2
    • Component/s: None
    • Labels:
      None

      Description

      Not entirely sure this is the right place but, when compiling an elixir piece of code I'm getting a internal error in beam_ssa_opt

      The generated stacktrace is:

      crash reason: {case_clause,
          {'EXIT',
              {{case_clause,{b_br,#{},{b_literal,nil},60,59}},
               [{beam_ssa_dead,is_br_safe,3,[{file,"beam_ssa_dead.erl"},{line,373}]},
                {beam_ssa_dead,shortcut_test_br,5,
                    [{file,"beam_ssa_dead.erl"},{line,209}]},
                {beam_ssa_dead,shortcut_two_way,5,
                    [{file,"beam_ssa_dead.erl"},{line,354}]},
                {beam_ssa_dead,shortcut_1,5,[{file,"beam_ssa_dead.erl"},{line,159}]},
                {beam_ssa_dead,shortcut_switch,5,
                    [{file,"beam_ssa_dead.erl"},{line,151}]},
                {beam_ssa_dead,shortcut_terminator,5,
                    [{file,"beam_ssa_dead.erl"},{line,142}]},
                {beam_ssa_dead,shortcut_opt,3,
                    [{file,"beam_ssa_dead.erl"},{line,106}]},
                {beam_ssa_dead,opt,1,[{file,"beam_ssa_dead.erl"},{line,61}]},
                {beam_ssa_opt,ssa_opt_dead,1,[{file,"beam_ssa_opt.erl"},{line,293}]},
                {compile,run_sub_passes_1,3,[{file,"compile.erl"},{line,439}]},
                {beam_ssa_opt,phase,4,[{file,"beam_ssa_opt.erl"},{line,82}]},
                {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
                {beam_ssa_opt,module,2,[{file,"beam_ssa_opt.erl"},{line,75}]},
                {compile,'-select_passes/2-anonymous-2-',3,
                    [{file,"compile.erl"},{line,672}]},
                {compile,'-internal_comp/5-anonymous-1-',3,
                    [{file,"compile.erl"},{line,396}]},
                {compile,fold_comp,4,[{file,"compile.erl"},{line,423}]},
                {compile,internal_comp,5,[{file,"compile.erl"},{line,407}]},
                {compile,'-do_compile/2-anonymous-0-',2,
                    [{file,"compile.erl"},{line,207}]},
                {elixir_erl_compiler,compile,4,
                    [{file,"src/elixir_erl_compiler.erl"},{line,52}]},
                {elixir_erl,load_form,5,
                    [{file,"src/elixir_erl.erl"},{line,439}]}]}}}
      
        in function  compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 672)
        in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 396)
        in call from compile:fold_comp/4 (compile.erl, line 423)
        in call from compile:internal_comp/5 (compile.erl, line 407)
        in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 207)
        in call from elixir_erl_compiler:compile/4 (src/elixir_erl_compiler.erl, line 52)
        in call from elixir_erl:load_form/5 (src/elixir_erl.erl, line 439)
        in call from elixir_erl_compiler:'-spawn/2-fun-0-'/3 (src/elixir_erl_compiler.erl, line 12)
          (stdlib) lists.erl:1338: :lists.foreach/2
          (elixir) src/elixir_erl_compiler.erl:12: anonymous fn/3 in :elixir_erl_compiler.spawn/2
          (elixir) lib/kernel/parallel_compiler.ex:208: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
      

      The offending piece of code is cond comparison between 4 booleans:

      cond do
        is_foo? and is_bar? ->
          "foobar"
      
        is_foo? and not is_baz? ->
          "foounbaz"
      
        not is_foo? and is_quux? ->
          "unfooquux"
      
        not is_foo? and not is_quux? ->
          "unfoounquux"
      end
      

      Of note is that, replacing it with a similar case passes compilation.

      case {is_foo?, is_bar?, is_baz?, is_quux?} do
          {true, true, _, _} ->
            "foobar"
      
          {true, _, false, _} ->
            "foounbaz"
      
          {false, _, _, true} ->
            "unfooquux"
      
          {false, _, _, false} ->
            "unfoounquux"
      end
      

        Attachments

          Activity

            People

            Assignee:
            bjorn Björn Gustavsson
            Reporter:
            camonz Simon Garcia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: