From: Bob Wilson Date: Thu, 13 Jan 2011 18:26:59 +0000 (+0000) Subject: Check for empty structs, and for consistency, zero-element arrays. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f0908aeade2f41d2fed82de8d85448358b379328;p=oota-llvm.git Check for empty structs, and for consistency, zero-element arrays. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123383 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 0ec095749f9..e248413f438 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1084,12 +1084,12 @@ static bool isHomogeneousAggregate(const Type *T, unsigned &NumElts, const Type *&EltTy) { if (const ArrayType *AT = dyn_cast(T)) { NumElts = AT->getNumElements(); - EltTy = AT->getElementType(); + EltTy = (NumElts == 0 ? 0 : AT->getElementType()); return true; } if (const StructType *ST = dyn_cast(T)) { NumElts = ST->getNumContainedTypes(); - EltTy = ST->getContainedType(0); + EltTy = (NumElts == 0 ? 0 : ST->getContainedType(0)); for (unsigned n = 1; n < NumElts; ++n) { if (ST->getContainedType(n) != EltTy) return false;