[llvm-commits] [PATCH 0/5] Reduce memory usage for phi operands

Chris Lattner clattner at apple.com
Tue Jun 21 12:03:42 PDT 2011


On Jun 21, 2011, at 5:57 AM, Jay Foad wrote:

>> If you're interested in another project, PR1324 would be another great memory reduction for apps with lots of strings and tables.
> 
> This bug is about using a more compact representation of
> ConstantArrays of ConstantInts. I think it will be easier to do this
> for integers of a few pre-defined widths (i8. i16, i32, i64, maybe
> even i1), rather than trying to handle arbitrarily wide integers. Does
> this seem reasonable?

That would be very reasonable.  The biggest memory savings come from strings and other simple tables.  I think that it would make sense to handle the "common" datatypes: arrays of i8/i16/i32/i64/float/double, which are the most common thing you see in tables.  A sketch of the class could be something like:


class ConstantDataArray {
…

  // To be used on arrays of ints.
  uint64_t getIntElement(uint64_t idx)

  // To be used on arrays of floats/doubles.
  APFloat getFloatElement(uint64_t idx)

};

The actual data would then just be stored in a normal C array.

To get one of these, the ConstantArray::get method would form one when the elements are simple enough, and clients like clang can use ConstantDataArray::get() directly for string constants and other cases.  Using ConstantDataArray directly is useful because it avoids creating the Constant*'s for the elements at all.

-Chris



More information about the llvm-commits mailing list