A am a bit stumbling forward. Current progress pushed on the mjw/dwarf_output branch. Not
stuck, just fighting and backtracking on some ideas. So best to give a little status
update in case more course corrections are necessary.
The local hash for dies is now no longer (re)calculated in the
dwarf_output::debug_info_entry hierarchy, but stored in the die_info. This is calculated
when the pending_entry is finalized. This also puts all calculations in one place.
This is slightly too late (or too early depending on how you look at it). Although at that
time all children of the die have already been finalized, not all (circular) references
have. But we are putting the candidate into the collector anyway.
At first I thought that I just needed to get rid of the attributes_type cache, since that
is where the reference chasing ends up. That would get rid of some complexity, but
doesn't actually solve the actual algorithmic problem. Then the reference chasing ends
up in the hash calculation of the debug_info_entry itself. So I abandoned that idea for
Instead what we need is to make sure that the local hash is calculated for every entry die
before we try to put the attributes_type (or debug_info_entry) into the collector, since
the full hash is based on the reference attributes, which can point to any die, and so
need their local hash set.
So I am now looking at only calculating the local hash when we currently finalize, but
don't put the items directly in the cache, but only after we scanned over the whole
CU. That way when we do put the item in the cache, we can calculate the full hash because
we can be sure that all dies that the reference attributes (recursively) points at have
their local hash set.