Hi,
I want to write a pass that pulls single-entry a single-exit (SESE) region into a function.
The idea is similar to extracting a loop in LoopExtractor.cpp.
Basically, for each region that meet our criteria,
- Find all basic blocks in that regions
- Call llvm::ExtractCodeRegion() to replace that region by a call to the extracted function.
- Delete the region from the RegionPassManager queue
- Update the RegionInfo to reflect the change
To find all basic blocks (step 1), I use Region::block_iterator().
However, after changing the CFG, that block_iterator does not seem to work anymore.
Should I add a list of basic blocks for each Region like what people did with Loop?
Thank you.