[llvm] 7b7c85d - [Bitcode] Check type of alloca size argument

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 03:48:42 PST 2023


Author: Nikita Popov
Date: 2023-12-11T12:48:34+01:00
New Revision: 7b7c85d156f327312e37a60c21a4a2093919c5e1

URL: https://github.com/llvm/llvm-project/commit/7b7c85d156f327312e37a60c21a4a2093919c5e1
DIFF: https://github.com/llvm/llvm-project/commit/7b7c85d156f327312e37a60c21a4a2093919c5e1.diff

LOG: [Bitcode] Check type of alloca size argument

This must be an integer. This check is present in LLParser but not
the BitcodeReader.

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 98c5e948dc596..e3451675c213f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5962,6 +5962,9 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
       if (!Align)
         Align = DL.getPrefTypeAlign(Ty);
 
+      if (!Size->getType()->isIntegerTy())
+        return error("alloca element count must have integer type");
+
       AllocaInst *AI = new AllocaInst(Ty, AS, Size, *Align);
       AI->setUsedWithInAlloca(InAlloca);
       AI->setSwiftError(SwiftError);


        


More information about the llvm-commits mailing list