<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 - wasm32-unknown-unknown-wasm target generated invalid code"
   href="https://bugs.llvm.org/show_bug.cgi?id=34317">34317</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wasm32-unknown-unknown-wasm target generated invalid code
          </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>sbc@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For the following C problems the wasm32-unknown-unknown-wasm generates invalid
wasm in that it includes an extra get_local which means that that type stack is
not empty when the function returns:

```
int main()
{
  int c = 1;
  asm(""::"r"(c));
  return 0;
}
```

With wasm32-unknown-unknown-wasm:

000043 <main>:
 000047: 41 01                      | i32.const 1
 000049: 21 00                      | set_local 0
 00004b: 20 00                      | get_local 0
 00004d: 41 00                      | i32.const 0
 00004f: 0b                         | end

With wasm32-unknown-unknown-elf:

000034 func[0]:
 000038: 41 01                      | i32.const 1
 00003a: 21 00                      | set_local 0
 00003c: 41 00                      | i32.const 0
 00003e: 0b                         | end

The result of running the back code in wasm-interp is:

error: type stack at end of function is 1, expected 0
000004d: error: EndFunctionBody callback failed</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>