[BitcodeReader] fix a logic error in vector type element validation

The current code checks whether the vector's element type is a valid structure element type, rather than a valid vector element type. The two have separate implementations and but only accept very slightly different sets of types, which is probably why this wasn't caught before.

Differential Revision: https://reviews.llvm.org/D109655
This commit is contained in:
william woodruff
2021-10-09 08:59:45 +05:30
committed by Shivam Gupta
parent 65df10f3cd
commit 778bf73d7b

View File

@@ -1926,7 +1926,7 @@ Error BitcodeReader::parseTypeTableBody() {
if (Record[0] == 0)
return error("Invalid vector length");
ResultTy = getTypeByID(Record[1]);
if (!ResultTy || !StructType::isValidElementType(ResultTy))
if (!ResultTy || !VectorType::isValidElementType(ResultTy))
return error("Invalid type");
bool Scalable = Record.size() > 2 ? Record[2] : false;
ResultTy = VectorType::get(ResultTy, Record[0], Scalable);