[llvm-commits] [llvm] r123381 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/copy-aggregate.ll

Bob Wilson bob.wilson at apple.com
Thu Jan 13 10:30:26 PST 2011


On Jan 13, 2011, at 10:18 AM, Frits van Bommel wrote:

> On Thu, Jan 13, 2011 at 6:45 PM, Bob Wilson <bob.wilson at apple.com> wrote:
>> +/// isHomogeneousAggregate - Check if type T is a struct or array containing
>> +/// elements of the same type (which is always true for arrays).  If so,
>> +/// return true with NumElts and EltTy set to the number of elements and the
>> +/// element type, respectively.
>> +static bool isHomogeneousAggregate(const Type *T, unsigned &NumElts,
>> +                                   const Type *&EltTy) {
>> +  if (const ArrayType *AT = dyn_cast<ArrayType>(T)) {
>> +    NumElts = AT->getNumElements();
>> +    EltTy = AT->getElementType();
>> +    return true;
>> +  }
>> +  if (const StructType *ST = dyn_cast<StructType>(T)) {
>> +    NumElts = ST->getNumContainedTypes();
>> +    EltTy = ST->getContainedType(0);
> 
> I don't think that works for empty structs...

Right.  Fixed in r123383.  Thanks!



More information about the llvm-commits mailing list