<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58438>58438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang wasm32 assembly typechecker rejects valid assembly input
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TerrorJack
</td>
</tr>
</table>
<pre>
Minimal repro:
```
a:
.functype a () -> (i32)
.local i32
loop i32
local.get 0
if i32
i32.const 0
if i32
br 2
else
i32.const 0
end_if
else
i32.const 0
end_if
end_loop
end_function
```
Command line:
```sh
clang-16 --target=wasm32-wasi -c ghc_3.s -o ghc_3.o
```
It fails with an error message:
```
ghc_3.s:10:4: error: end: insufficient values on the type stack
else
^
```
If it's compiled with `clang-16 --target=wasm32-wasi -c -Wa,--no-type-check ghc_3.s -o ghc_3.o`, then it compiles fine, and produces an object that passes typechecking with `wasm2wat`.
Tested with latest official ubuntu 22.04 apt build:
```
$ clang-16 --version
clang-16 --version
Ubuntu clang version 16.0.0-++20221018042346+a8c92b69e72e-1~exp1~20221018042459.490
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVEtvqzgU_jVmc2TkGEJgwaLTdqQZ6e46mmVljAFPjY2w6ePf32NIbtLcpprI8ePzx3kfN679qH9oq0dhYFbT7Eh2R9gDYae5YMexHsXFdZV2i5XhY1IggPCS8AooyR7jXmccj2emcRIVQIRPmHFu-gSsGNLSXgVgl7DurokRzHgqnfVX3Ft0HM0M16gyXv1OvC1a2fZZd5fgFxJufH71bTzGGHwC1ohqZ78M_jbfu3EUtgWjrbqVLD9sgDTC9nRXAKVBzBhXkj28CT9mnOKigUroB_mcpR6oO27dN7r_CtAJbTy86TCAsKDm2c0wKu9Ff9Oa7XhUhKQdwynH__b5urFtXLT1S9dpqZUN8CrMojw4C2FQsNaZD0K-bOLgxu-cj1sMsn_8zkUsnkD4wYN046SNajdnkfY_okn_FYTfU2odjQZTOSj58lWMUSm_j45ZVHdS5aGLScWLmGBsxnaRCGKcXfOfkgH5IsAkvEc0yl_Fa9v_MjGaw99EwG166dWT8uHkiREBT-DWQGNXLs1iwwKcpywHMQVoFm3a75NJeA4X4XhVs_9VtbfwfzY96zUcb2BXpCxllPA_cHDG-Y7tSpbzLC8QEKWseFNU6sAV3ZHDo3qf4nJBzPdVmldHs56OabmD97J4LnI6SYp9srzT3i5HyjAr0cLoWmUicXJevx9Tjy0rDGb8Qa9FSfifi59xbvR1Qyaq3hVFwaq83FdJW2dtlVUiCToYVW8ebpUBMVljYz7O-VIzvrQxnT6WuG7PFG2nJSTLbOohhCm2CirH0WPalgbflBEPxryeFoolEgXhUXuPzYKbfZlnZTLUbS552ci9YqIoRF51vGKy6grG9wxj1iZGNNgrNdlj5LlVb7CKwD3ZPyS6PoV4x9khq9Iybw5FeWBCFSqr8orkTI34FKTRjtTNfTLXq0nN0nu8NNoHf75EF3VvlVrVoXyxhMHN9dP6APyNTZ2s2uvV-p9Sdd4Y">