[LLVMdev] How to force the creation of arrays with zeroes?
baldrick at free.fr
Fri Jan 20 04:50:30 CST 2012
>> you can't, you can only get a ConstantAggregateZero. This is actually kind of
>> annoying, and means that places expecting a ConstantArray have to remember to
>> also check for ConstantAggregateZero. Perhaps there's a good reason for the
>> current design, but if not it would be great to eliminate this wart.
> Well, I think the main reason it so reduce the size of .ll / .bc when
> all operands are zero.
> If the array / struct is really big then this can save a lot of space.
isn't this an orthogonal issue? A ConstantVector consisting of only zeros
doesn't have to be represented by storing a vast array of zero values, it
could be special cased internally by setting some kind of flag. If done right,
an all zero ConstantVector would then act exactly the same as every other kind
of ConstantVector as far as users of ConstantVector can tell, but wouldn't take
up a lot of storage. Instead, what we have now is essentially the same system
only with the flag exposed to users (ConstantAggregateZero playing the role of
the flag) so that all users have to worry about it, rather than this flag being
hidden in the implementation of ConstantVector and ConstantStruct.
More information about the LLVMdev