7 Commits

Author SHA1 Message Date
Jessica Paquette
9c0a349788 Revert "[SuffixTree] Add suffix tree statistics"
This reverts commit d3a6a05b1f95564f2c66f885a83cf0dbe1a004a9.

Some bots don't like it.

Boo.
2023-05-12 17:09:26 -07:00
Jessica Paquette
d3a6a05b1f [SuffixTree] Add suffix tree statistics
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.
2023-05-12 17:05:04 -07:00
Jessica Paquette
c2eeaf105a [NFC] SuffixTree: Move advance() into SuffixTree.cpp + more cleanup
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.
2023-05-11 22:29:47 -07:00
Jessica Paquette
66520c04cf [NFC] SuffixTree: Move EmptyIdx into SuffixTreeNode and add a root allocator
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.
2023-05-11 20:41:49 -07:00
Jessica Paquette
c2f0c204d1 [NFC] Refactor SuffixTree to use LLVM-style RTTI
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
2023-05-11 17:50:21 -07:00
Jessica Paquette
ec37ebf59b [NFC] Use SmallVector/ArrayRef in MachineOutliner/SuffixTree for small types
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.
2023-02-03 16:41:02 -08:00
Andrew Litteken
bb677cacc8 [SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit Tests
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
2020-06-08 12:44:18 -07:00