<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/84910>84910</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"Illegal VarBitInit expression!" assertion failed in llvm-tblgen
</td>
</tr>
<tr>
<th>Labels</th>
<td>
tablegen,
crash-on-invalid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jayfoad
</td>
</tr>
</table>
<pre>
With this example:
```
class A<bits<8> op> {
bits<8> f = op;
}
multiclass B<bits<8> op> {
def : A<op>;
}
multiclass C<bits<4> op> : B<op>;
defm D : C<0>;
```
I get:
```
$ llvm-tblgen crash.td
llvm-tblgen: include/llvm/TableGen/Record.h:1285: llvm::VarBitInit::VarBitInit(llvm::TypedInit *, unsigned int): Assertion `T->getType() && (isa<IntRecTy>(T->getType()) || (isa<BitsRecTy>(T->getType()) && cast<BitsRecTy>(T->getType())->getNumBits() > B)) && "Illegal VarBitInit expression!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```
It looks like some missing type checking when multiclass C passes its `bits<4>` argument into multiclass B which was expecting a `bits<8>`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2P4zYM_TX0hRjDoZzEOfjgfBUDFEWxHbRnWWZs7cgfsOidzb8vZM82CbbtDhYwDEuP79F6JKW9t3XHnMN6D-tjpCdp-jH_rK-XXldR2VfX_C8rDUpjPfJX3Q6OQRWQHCEpYJO8P_PSOO09FqAOpRUP6pCBOmE_hDds90sQ4j14QVDHOeQdhu1x-WgnJ3ZR3P9IseKgU8ypZ_B_5Q43ufROThVzokd-xZcWjzMYaMmD9uPpn7Fm-S9rgFJ07kv7JKWruUMzat_EUi3oHRIy2c64qWKgcwCAzi-6dPwLd0DnT2z6sYobUMWKsnUIn4NUAar4U497K8-dle_WlN3CXq4DV2EXgQqgA07d3AUV2k6AdrOV3vMotu8QNsnLE6hTzRKIQBnQDoE2QBsEyqzXoA7PnXxi83INBlH2PWHmbA-wPdw4eyv-x6QlkdFePkh53_ttakP0t_9VJ9w_SgLRs3Nca4c3o5C_DiN7b_sOaAVEQFu8aOu4ipdi_f7rqfjjhH4qWyuosZxqHHnoR0HpsREZfLCZzkDn2kozlbHp21sx52IPY_-ZjQCdrfcTe6Az6q76VnqUhpcewVKbVxm14fjfu07Q9f2rR2dfGX3fMrbWe9vVKNeB0TRsXsPqreEO76cAB-09e7TiQ43vJgI2CeqxnlruJLREf8_b41tjTYNvOtwHAxsJ6vpOIlsk4qjKVbVTOx1xvtquElonaZpFTZ6lGeutostmpcy6VMl6k1a8TcxGq5SNiWxOCaWJWtFKqTTJYmW0qUxVXi47nZaGIU241dbFwcy4H-totjHP0t0qiZwu2fn5SiOSMDthsEIpD0A02_rUd0-2-6KdrQKwPkZjPhemnGoPaeKsF39TFyuO8481DOp_RmfpG7Td_exH0-jyn2-T-Yh_BwAA__9wJ7bO">