Commit Graph

3 Commits

Author SHA1 Message Date
Michael Gottesman
59c89e56ce [g-arc-opts] Change Global ARC Sequence Dataflow to use PreallocatedMap.
This will speed up the optimizer by reducing the amount of allocations
we perform while running the optimizer.

Swift SVN r18762
2014-06-09 23:09:04 +00:00
Michael Gottesman
df5f9dbf6f Fix up preallocated array to deallocate memory.
I made a wrong assumption that the allocators would deallocate the
memory when their destructor was being called. Turns out this is not
true evidently.

Swift SVN r18753
2014-06-09 20:27:35 +00:00
Michael Gottesman
a301dbe548 Add in PreallocatedArray, PreallocatedMap data structures.
These arrays are meant to be used in situations where you want to allocate a
potentially large amount of default constructible items for a collection of
fixed size.

An example of such a use case is for data flow algorithms which need a
one to one mapping from BB -> StateObject. In such a case, if the state
object is default constructible, we can allocate all of the structures
first, initialize them for each BB, and then process as we normally
would. Thus we eliminate overhead due to memory allocation.

Since the data structures take an allocator it also enables one to use it in
cases where one allocates memory from an allocator and references it via an
ArrayRef. We do this in swift when storing data into certain instructions.

Another benefit over using DenseMaps in such cases is that a DenseMap (unless
you preallocate) can cause all sorts of invalidation issues as new states are
added.

I am planning on using this in my Enum Simplification work and changing
the Global ARC Optimizer to use this.

Swift SVN r18739
2014-06-08 22:52:12 +00:00