From 4f04db4b5439f390c48408f9b94875810e88ffc6 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 15 May 2020 13:23:14 -0700 Subject: AllocaInst should store Align instead of MaybeAlign. Along the lines of D77454 and D79968. Unlike loads and stores, the default alignment is getPrefTypeAlign, to match the existing handling in various places, including SelectionDAG and InstCombine. Differential Revision: https://reviews.llvm.org/D80044 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (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 7b62bab..e95d7b1 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4826,7 +4826,13 @@ Error BitcodeReader::parseFunctionBody(Function *F) { const DataLayout &DL = TheModule->getDataLayout(); unsigned AS = DL.getAllocaAddrSpace(); - AllocaInst *AI = new AllocaInst(Ty, AS, Size, Align); + SmallPtrSet Visited; + if (!Align && !Ty->isSized(&Visited)) + return error("alloca of unsized type"); + if (!Align) + Align = DL.getPrefTypeAlign(Ty); + + AllocaInst *AI = new AllocaInst(Ty, AS, Size, *Align); AI->setUsedWithInAlloca(InAlloca); AI->setSwiftError(SwiftError); I = AI; -- cgit v1.1