I am writing a pass in llvm that would identify loop invariants and hoist those instructions who are using those invariants, above the loop body. But for that i need to know whether there is any back edge from one node to another. For e.g. I want to find whether there is a back edge from node N to node H, where node H dominates node N, that would help me identify a natural loop. How can i find whether there is any edge from one node to another in the CFG ? I could not found any class called CFG in LLVM from which i could gather this information.
Asked
Active
Viewed 1,831 times
2 Answers
0
If you call the loop-simplify pass it will guarantee that there is only a single back edge to the loop header. This is a transformation pass so the CFG is modified but it makes additional CFG hacking far simpler.

laprej
- 138
- 1
- 5