[llvm] 778bf73 - [BitcodeReader] fix a logic error in vector type element validation

Shivam Gupta via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 21:11:58 PDT 2021


Author: william woodruff
Date: 2021-10-09T09:42:02+05:30
New Revision: 778bf73d7ba693f4bb74d137a70870bce128a19f

URL: https://github.com/llvm/llvm-project/commit/778bf73d7ba693f4bb74d137a70870bce128a19f
DIFF: https://github.com/llvm/llvm-project/commit/778bf73d7ba693f4bb74d137a70870bce128a19f.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index f5503d6e8eeb..b3df3a759d97 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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);


        


More information about the llvm-commits mailing list