Essentially, fold OrderedBasicBlock into BasicBlock, and make it
auto-invalidate the instruction ordering when new instructions are
added. Notably, we don't need to invalidate it when removing
instructions, which is helpful when a pass mostly delete dead
instructions rather than transforming them.
This dramatically speeds up clang compiling clang with debug info.
Compiling SemaChecking.cpp on my computer previously took 121s, and now
it takes 74s, for a 63% speedup.
The downside is that Instruction grows from 56 bytes to 64 bytes, and I
don't have a good way to measure what that costs in practice. As the one
who removed the vtable from Value, I will say that this is how I would
like to spend the 8 bytes that I saved a year ago in r303362.
The resulting LLVM code is substantially simpler and automatically
handles invalidation, which makes me think that this is the right speed
and size tradeoff. There's more low-hanging fruit in MemorySSA and DSE,
which maintain their own instruction orderings today.
The code isn't completely polished, I just wanted to post some numbers
and show people what this looks like. The important change is in
SymbolTableTraitsImpl.h, where the numbering is invalidated. Everything
else should be straightforward.
We could implement a fancier re-numbering scheme, but I think we should
wait and profile and see if we really need that complexity. If we do,
the APIs will stay the same anyway, so this is a good first step.