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
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 6a8712e..e035c66 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -172,6 +172,9 @@
   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());