llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

"Illegal VarBitInit expression!" assertion failed in llvm-tblgen

Open jayfoad opened this issue 2 years ago • 2 comments

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>.

jayfoad avatar Mar 12 '24 13:03 jayfoad

Here's another repro for the same error message:

class C<bit val> {
  bits<32> word;
  bit flag;
  let word{0} = !cond(val : flag);
}
class D<bit val> : C<val>;

jayfoad avatar Jun 23 '25 16:06 jayfoad

https://github.com/llvm/llvm-project/pull/197128 is the resolution , @jayfoad . : )

jofrn avatar May 12 '26 09:05 jofrn