<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/79966>79966</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            wasm assembly type checker throws incorrect error
        </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>
    Consider the following example:

```asm
.section .text.foobar,"",@
.hidden foobar
.globl foobar
foobar:
  .functype foobar () -> (i32)
 i32.const 0
  table.get __indirect_function_table
  i32.const 42
 table.grow __indirect_function_table
 end_function
```

```c
#include <stdio.h>

int foobar(void);

int main(void) {
  printf("%d\n", foobar());
 printf("%d\n", foobar());
}
```

When compiling with `clang -mreference-types -O3 foobar.s asdf.c -o asdf.wasm -Wl,--growable-table`, it outputs the following error:

```
foobar.s:9:3: error: popped funcref, expected externref
  table.grow __indirect_function_table
 ^
```

But if I forcibly disable the wasm assembly type checker with `-Wa,--no-type-check`, then it compiles and runs just fine. The issue above is reported with latest llvm `master`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE1vqzgU_TVmcwUyNpCwYNGmjTSzmc2TuqyMfQl-z9jINk3770cmpGmrmc7oSShxru-5H-ecIELQJ4vYkfqe1A-ZWOLofPcDvXf-TyF_Zb1Tb93B2aAVeogjwuCMcWdtT4CvYpoNEn5H6AOh18-GXh4RpkukCCijdhaKiK-xGJzrhSfsQBhbnwOp6JY5aqXQwpZyiZ2M682n0Ha-9gUohsXK-DbjlgaE7QlrISf8MZ01Z4S1W7bmrJDOhgj0io-iN1icMMLzs7ZKe5Txea2pnX1eb6-pN3TFttiG9u78n3C06v3iC13_yKHcfjOurTSLQiD8EKLSrhgJf_yI0TZeSWL7F6dV2pjff02ZhLa3BCC7--tms9c2DitzjLBakfpgL_rc6qaaH8r-DobsHr7Z_GlEC9JNszbJYmcdR0g8GGFPkE8eB_RoJeZJ7QD5X3xrVAQQQQ2FhNxdTmcRJsifDGGHPE_qJB3yixoNTSPqCG6J8xLDV2cn__-brz96sAiE37WE33HC795hMLt5RgVJaY9DaoWvM8qICvA1orcp-tl7_8c9pH78hrr7JYIe4A8YnJe6N2-gdEjodbmVDRECTulm_a_IEeUv9O8k509i5cq6ld18vd-oikkXHTdpMICwCvxiA_xcQoRBWyzgx4igQ1gQRO9e0hk8zs6nvdcmRkQMEYx5mVLDSYSInjS0yFTHVctbkWFX7mjTUF63ZTZ2DWuqnpa9pJJWjapKRvu9wLrZ7WS75zzTHaOsoiWndM95SYt9va-wbFTDmn1TljtSUZyENkXqWjh_ytYRu13bNk1mRI8mrO8_xiyeL_MnC9cPme8SJu-XUyAVNTrEcKsSdTTYfUNrHL07B9BWOp80vdgjW7zpxhjn5BzCjoQdTzqOS19INxF2TPW3r3z27ifKSNhxnSoQdlyn_jsAAP__VqW_4g">