<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Error: WebAssembly hasn't implemented computed gotos in Emscripten's latest-upstream llvm/trunk backend"
   href="https://bugs.llvm.org/show_bug.cgi?id=42498">42498</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Error: WebAssembly hasn't implemented computed gotos in Emscripten's latest-upstream llvm/trunk backend
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: WebAssembly
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rverschelde@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This might be a known issue as it's an unimplemented feature, but it might be
worth tracking here, especially as Emscripten is moving from their fastcomp
fork (which seems to support gotos) to llvm upstream/trunk (which apparently
does not).

When attempting to compile Godot Engine's master branch
(<a href="https://github.com/godotengine/godot">https://github.com/godotengine/godot</a>) with latest Emscripten and its
latest-upstream llvm/trunk backend, the following error is raised:

---

modules/gdscript/gdscript_function.cpp:262:27: error: WebAssembly hasn't
implemented computed gotos
Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant
**p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
                          ^
modules/gdscript/gdscript_function.cpp:262:27: error: WebAssembly hasn't
implemented computed gotos
fatal error: error in backend: Cannot select: t11: ch = brind t0, t10
  t10: i32,ch = load<(load 4 from %ir.indirect.goto.dest.in, !tbaa !58)> t0,
t12, undef:i32
    t12: i32 = add t8, t14
      t8: i32 = shl t5, Constant:i32<2>
        t5: i32,ch = load<(load 4 from %ir..pn.in, !tbaa !45)> t0, t2,
undef:i32
          t2: i32,ch = CopyFromReg t0, Register:i32 %1446
            t1: i32 = Register %1446
          t4: i32 = undef
        t7: i32 = Constant<2>
      t14: i32 = WebAssemblyISD::Wrapper TargetGlobalAddress:i32<[40 x i8*]*
@_ZZN16GDScriptFunction4callEP16GDScriptInstancePPK7VariantiRNS2_9CallErrorEPNS_9CallStateEE16switch_table_ops>
0
        t13: i32 = TargetGlobalAddress<[40 x i8*]*
@_ZZN16GDScriptFunction4callEP16GDScriptInstancePPK7VariantiRNS2_9CallErrorEPNS_9CallStateEE16switch_table_ops>
0
    t4: i32 = undef
In function:
_ZN16GDScriptFunction4callEP16GDScriptInstancePPK7VariantiRNS2_9CallErrorEPNS_9CallStateE
clang-9: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 9.0.0
(/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project
039af0ea03f987654a162b6160399a00fd22b1b0)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/akien/Projects/godot/emscripten/emsdk/upstream/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/gdscript_function-d03862.cpp
clang-9: note: diagnostic msg: /tmp/gdscript_function-d03862.sh
clang-9: note: diagnostic msg: 

********************
shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting

---

See <a href="https://github.com/godotengine/godot/issues/30248">https://github.com/godotengine/godot/issues/30248</a> for details.
The files mentioned in the above error are included in that issue.

Steps to reproduce:
- Clone <a href="https://github.com/godotengine/godot">https://github.com/godotengine/godot</a>
- Install Emscripten as per
<a href="https://emscripten.org/docs/getting_started/downloads.html">https://emscripten.org/docs/getting_started/downloads.html</a>, but use
`latest-upstream` instead of `latest` in the `./emsdk` commands
- Compile with `scons p=javascript target=release`

I haven't yet tried to make a minimal reproduction project as I'm not so
familiar with Emscripten, but I'll attempt it soon and post an update when I
do.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>