summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-07-27 17:47:54 +0000
committerTim Northover <tnorthover@apple.com>2016-07-27 17:47:54 +0000
commit8d2f52e035ceb361d3410d2b76b48a287c529356 (patch)
treeba4097b350146a830a1c97b25515b5e0a3440755 /llvm/lib/CodeGen
parentebebd6d2ff8430a32d294819ee05001f21a9808b (diff)
downloadbcm5719-llvm-8d2f52e035ceb361d3410d2b76b48a287c529356.tar.gz
bcm5719-llvm-8d2f52e035ceb361d3410d2b76b48a287c529356.zip
GlobalISel: support zero-sized allocas
All allocas must be at least 1 byte at the MachineIR level so we allocate just one byte. llvm-svn: 276897
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 6a8712e184b..e035c66b24a 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -172,6 +172,9 @@ bool IRTranslator::translateStaticAlloca(const AllocaInst &AI) {
unsigned Size =
ElementSize * cast<ConstantInt>(AI.getArraySize())->getZExtValue();
+ // Always allocate at least one byte.
+ Size = std::max(Size, 1u);
+
unsigned Alignment = AI.getAlignment();
if (!Alignment)
Alignment = DL->getABITypeAlignment(AI.getAllocatedType());
OpenPOWER on IntegriCloud