const Type *ElementType = getType(ElTyp);
if (ElementType == 0) return failure(Val);
- int NumElements;
+ unsigned NumElements;
if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
case Type::ArrayTyID: {
const ArrayType *AT = cast<const ArrayType>(Ty);
- unsigned NumElements;
- if (AT->isSized()) // Sized array, # elements stored in type!
- NumElements = (unsigned)AT->getNumElements();
- else // Unsized array, # elements stored in stream!
- if (read_vbr(Buf, EndBuf, NumElements)) return failure(true);
+ unsigned NumElements = AT->getNumElements();
vector<Constant*> Elements;
while (NumElements--) { // Read all of the elements of the constant.
break;
}
default:
+ BCR_TRACE(5, "UNKNOWN Pointer Constant Type!\n");
return failure(true);
}
break;
case Type::ArrayTyID: {
const ConstantArray *CPA = cast<const ConstantArray>(CPV);
unsigned size = CPA->getValues().size();
- if (!((const ArrayType *)CPA->getType())->isSized())
- output_vbr(size, Out); // Not for sized arrays!!!
-
+ assert(size == cast<ArrayType>(CPA->getType())->getNumElements() && "ConstantArray out of whack!");
for (unsigned i = 0; i < size; i++) {
int Slot = Table.getValSlot(CPA->getOperand(i));
assert(Slot != -1 && "Constant used but not available!!");
ArrayType *aty = cast<ArrayType>(CPA->getType());
if (ArrayTypeIsString(aty))
return 1 + CPA->getNumOperands();
- else if (! aty->isSized())
- return 0;
}
return target.findOptimalStorageSize(CV->getType());
}
// Get the size of the type and then use SizeToAlignment.
-// If this is an unsized array, just return the L1 cache line size
-// (viz., the default behavior for large global objects).
//
inline unsigned int
TypeToAlignment(const Type* type, const TargetMachine& target)
{
- if (ArrayType* aty = dyn_cast<ArrayType>(type))
- if (! aty->isSized())
- return target.getCacheInfo().getCacheLineSize(1);
-
return SizeToAlignment(target.findOptimalStorageSize(type), target);
}