This pass will lower all parallel regions to sequential IR. It replaces
PIR instruction by unconditional branch instructions as follows:
- fork is replaced with a branch to the forked block.
- halt is replaced with a branch to the sibling continuation block.
- join is replaced with a branch to its destination block.
This approach:
- Does not need to scan the function if there are no parallel regions.
- Emits llvm.mem.parallel_loop_access metadata for parallel loops that have been sequentialized.
- Preserves the DominatorTree, LoopInfo and ParallelRegionInfo.
This commit also includes general infrastructure needed for PIR passes as well as a library (libPIR) for the passes to live in.
TODO: We can use the parallel region info pass to avoid a linear walk of the function here.