Index: include/llvm/TableGen/Record.h =================================================================== --- include/llvm/TableGen/Record.h +++ include/llvm/TableGen/Record.h @@ -1241,6 +1241,8 @@ bool setValue(Init *V) { if (V) { Value = V->convertInitializerTo(getType()); + assert(!Value || !isa(Value) || + cast(Value)->getType()->typeIsConvertibleTo(getType())); return Value == nullptr; } Value = nullptr; Index: lib/TableGen/Record.cpp =================================================================== --- lib/TableGen/Record.cpp +++ lib/TableGen/Record.cpp @@ -478,6 +478,9 @@ if (ListInit *I = ThePool.FindNodeOrInsertPos(ID, IP)) return I; + assert(Range.empty() || !isa(Range[0]) || + cast(Range[0])->getType()->typeIsConvertibleTo(EltTy)); + void *Mem = Allocator.Allocate(totalSizeToAlloc(Range.size()), alignof(ListInit)); ListInit *I = new(Mem) ListInit(Range.size(), EltTy);