Calculate LoopInfo again

Hello,
I am iterating over loops using LoopInfo iterator. If a condition satisfies on some loop, I change the loop body and remove it from that particular loop. Also, I remove all incoming edges to the loop header, latch and preHeader. Hence, these will be the unreachable blocks in the function.

If that condition satisfies, then I start iterating the loops from the beginning skipping the modified loop. So, I need to re-calculate the LoopInfo.

How to build LoopInfo again with the updated CFG structure?

If I just call getAnalysis() again, the modified loop will still be present in it.

You can re-create LoopInfo from updated dominator tree.

Just update dominator tree for function and check LoopInfo::Analyze for new LoopInfo.

Regards,

Ashutosh