Reland "[mlir] Fix false positive loops in RegionBranchOpInterface::hasLoop" (#234591)
Relands #233784, reverted in #234573 because it broke two CIR unit
tests.
Those tests expected hasLoop() to be true for cir.await and
cir.coroutine, although neither has a cycle: resume is reachable from
ready both directly and through suspend, and the coroutine reaches exit
and destroy along several paths. That was the false positive this change
fixes. The relanded change updates both expectations to false.
Original description:
`RegionBranchOpInterface::hasLoop` reported a loop whenever its
traversal popped a region it had already visited. The worklist gets one
entry per successor of each terminator, so a region reachable along two
paths was popped twice even without a cycle, for example when two
terminators of a region branch to the same successor region.
`hasLoop` now runs one iterative depth-first search from the entry
regions and reports a loop only when it reaches a region that is still
on the DFS stack. Each region is queried at most once, through
`RegionBranchOpInterface::getSuccessorRegions(Region &)` instead of
asking each terminator with null operand attributes. The stop condition
of the remaining traversal loses its `visited` argument.
Assisted-by: Claude Code (Claude Opus 5.5)