[BitcodeReader] fix a logic error in vector type element validation
source link: https://reviews.llvm.org/D109655
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.
Event Timeline
Increase the context for the patch.
Thanks! I don't have commit access so I'll need someone else to do the merge :-)
just doing after a check-llvm.
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Show First 20 Lines • Show All 1,920 Lines • ▼ Show 20 Lines case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] break; break; case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] or case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] or // [numelts, eltty, scalable] // [numelts, eltty, scalable] if (Record.size() < 2) if (Record.size() < 2) return error("Invalid record"); return error("Invalid record"); if (Record[0] == 0) if (Record[0] == 0) return error("Invalid vector length"); return error("Invalid vector length"); ResultTy = getTypeByID(Record[1]); ResultTy = getTypeByID(Record[1]); if (!ResultTy || !StructType::isValidElementType(ResultTy)) if (!ResultTy || !VectorType::isValidElementType(ResultTy)) return error("Invalid type"); return error("Invalid type"); bool Scalable = Record.size() > 2 ? Record[2] : false; bool Scalable = Record.size() > 2 ? Record[2] : false; ResultTy = VectorType::get(ResultTy, Record[0], Scalable); ResultTy = VectorType::get(ResultTy, Record[0], Scalable); break; break; } }
if (NumRecords >= TypeList.size()) if (NumRecords >= TypeList.size()) return error("Invalid TYPE table"); return error("Invalid TYPE table"); ▲ Show 20 Lines • Show All 5,149 Lines • Show Last 20 Lines
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK