This patch introduces the DIEData class, which stores a sequence of DWARF
DIEs directly in the format in which they will be emitted to the object file
(i.e. bytes and relocations), together with the DIEWriter class, which is
used to add DIEs to a DIEData. The goal is to decrease memory consumption
in the DWARF emitter by migrating all DIE emission to go through these
classes instead of the current memory-inefficient DIE and DIEValue classes
(see mailing list thread [1]).
This patch also takes the first step towards migrating the DWARF emitter. It
introduces the necessary scaffolding for the migration in the form of the
ability for a DIE to use a DIEData-based representation, and replaces the
existing DWARF emission code for base types with code that uses DIEData.
To avoid a regression in memory consumption, I coded my changes to DIE to
avoid increasing its size.
A few notes on this patch:
- This doesn't add any support for relocations (other than symbol relocations) or insertions as mentioned in the thread, because they aren't needed to emit base types, and I wanted to make this first patch as simple as possible. Future patches will add this as needed.
- The way that the current DWARF hasher code works is by walking DIE entries. This won't work in the new world, so I've added a new mechanism for generating a hash from metadata. To get from a DIE to metadata, I store a reference to the MDNode in the DIE. I reckon that hashes will eventually be computed by walking MDNodes directly starting at a compilation unit or type, perhaps supplemented by additional information collected by walking the IR, so you can see how the current code might evolve into that.
This code isn't very DRY, but I think we can address this as needed as we migrate more tags to DIEData.
- The old and new abbreviation emitter code don't interact except by choosing to use different abbreviation numbers (the old code uses odd numbers, the new code uses even numbers).
[1] http://lists.llvm.org/pipermail/llvm-dev/2016-February/094974.html
Certainly the most important part of the review :-)
We enable autobrief in Doxygen now. In most situations \brief is redundant now.