Sometimes you want to see how much is being allocated in your data structure
in general.
Add statistics that show how many internal and leaf nodes have been allocated
in the suffix tree over the course of its construction.
Also add a testcase that shows that we actually get these stats out when we're
outlining stuff.
The test shows that we get the expected O(n) leaf nodes, a split, and so on.
Allows us to knock out a couple more includes from the header file.
Also clang-format SuffixTree.cpp while we're here.
Also use SuffixTreeNode::EmptyIdx in a couple more places.
This makes it clearer that EmptyIdx is related to the node.
Also add an allocator for the root so that in the main SuffixTree code we don't
see gross stuff like a nullptr parent etc.
Following guidelines in
https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
This allows us to
* Quickly discern between leaf and internal nodes
* Be more idiomatic with the rest of LLVM
* Save some size on node structs
* Reduce the number of allocations (because end indices for internal nodes no
longer need to be pointers to be compatible with leaf nodes)
Also object orientify the code some more. This allows for more asserts and
checks.
This shouldn't impact code size on the MachineOutliner.
- All unit tests pass (outliner lit + llvm-unit)
- No code size changes on CTMark @ -Oz for AArch64
The MachineOutliner + SuffixTree both used `std::vector` everywhere because I
didn't know any better at the time.
At least for small types, such as `unsigned` and iterators, I can't see any
particular reason to use std::vector over `SmallVector` here.
This moves the SuffixTree test used in the Machine Outliner and moves it into Support for use in other outliners elsewhere in the compilation pipeline.
Differential Revision: https://reviews.llvm.org/D80586