Extracting the similar regions is the first step in the IROutliner.
Using the IRSimilarityIdentifier, we collect the SimilarityGroups and sort them by how many instructions will be removed. Each IRSimilarityCandidate is used to define an OutlinableRegion. Each region is ordered by their occurrence in the Module and the regions that are not compatible with previously outlined regions are discarded.
Each region is then extracted with the CodeExtractor into its own function.
We test that correctly extract in:
- test/Transforms/IROutliner/extraction.ll
- test/Transforms/IROutliner/address-taken.ll
- test/Transforms/IROutliner/outlining-same-globals.ll
- test/Transforms/IROutliner/outlining-same-constants.ll
- test/Transforms/IROutliner/outlining-different-structure.ll
Try not to introducing global namespace types and variables (I fixed one in b69fe48ccf9ec19f6237ee2e9d16fc6a7071c17c)