aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2020-05-15 13:23:14 -0700
committerEli Friedman <efriedma@quicinc.com>2020-05-16 14:53:16 -0700
commit4f04db4b5439f390c48408f9b94875810e88ffc6 (patch)
tree72b1cdccd1d20e5d5081cfabeeaa5b3ea90b3c18 /llvm/lib/Bitcode
parent135b877874fae96b4372c8a3fbfaa8ff44ff86e3 (diff)
downloadllvm-4f04db4b5439f390c48408f9b94875810e88ffc6.zip
llvm-4f04db4b5439f390c48408f9b94875810e88ffc6.tar.gz
llvm-4f04db4b5439f390c48408f9b94875810e88ffc6.tar.bz2
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
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp8
1 files changed, 7 insertions, 1 deletions
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<Type *, 4> 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;