[MLIR][DataFlow] Fix two crashes in DeadCodeAnalysis on empty/no-terminator regions (#188548)

Two related assertion failures in DeadCodeAnalysis when processing
OpenACC operations:

1. visitRegionBranchEdges (issue #187972): When a RegionSuccessor refers
to an empty region (no blocks), calling getSuccessor()->front()
dereferences a sentinel ilist iterator, crashing with
"\!NodePtr->isKnownSentinel()". Fix: skip successors whose region is
empty.

2. isRegionOrCallableReturn (issue #188408): When iterating over ops in
a nested acc region whose blocks do not have a required terminator,
Block::getTerminator() is called without first checking
mightHaveTerminator(), triggering "Assertion `mightHaveTerminator()'
failed". Fix: guard the getTerminator() call with mightHaveTerminator().

Fixes #187972, #188408

Assisted-by: Claude Code
GitOrigin-RevId: 820eaa427a14566856a3d5f8104605a4a352a822
2 files changed
tree: c5996812a16d2f336066e403acb4b7ba31aa96e0
  1. benchmark/
  2. cmake/
  3. docs/
  4. examples/
  5. include/
  6. lib/
  7. python/
  8. test/
  9. tools/
  10. unittests/
  11. utils/
  12. .clang-format
  13. .clang-tidy
  14. CMakeLists.txt
  15. LICENSE.TXT
  16. Maintainers.md
  17. README.md
README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.