From 7b7c85d156f327312e37a60c21a4a2093919c5e1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 11 Dec 2023 12:45:22 +0100 Subject: [Bitcode] Check type of alloca size argument This must be an integer. This check is present in LLParser but not the BitcodeReader. --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 98c5e94..e345167 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); -- cgit v1.1