[clang] [CIR] Fix cir.cleanup.scope successor regions (PR #221222)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 23:19:04 PDT 2026
================
@@ -2037,14 +2037,31 @@ LogicalResult cir::CleanupScopeOp::verify() {
void cir::CleanupScopeOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
- if (!point.isParent()) {
- regions.emplace_back(getOperation());
+ // Execution always starts in the body region.
+ if (point.isParent()) {
+ regions.emplace_back(&getBodyRegion());
return;
}
- // Execution always proceeds from the body region to the cleanup region.
- regions.push_back(RegionSuccessor(&getBodyRegion()));
- regions.push_back(RegionSuccessor(&getCleanupRegion()));
+ mlir::Operation *term = point.getTerminatorPredecessorOrNull();
+ assert(term && "expected a terminator predecessor");
+
+ if (term->getParentRegion() == &getBodyRegion()) {
----------------
xlauko wrote:
No. `cir.unreachable` and `cir.trap` don’t implement `RegionBranchTerminatorOpInterface`, so they aren’t branch points and get no outgoing edges. That’s right, since control never leaves through them and no cleanup runs.
Coroutine terminators should be handled correctly.
https://github.com/llvm/llvm-project/pull/221222
More information about the cfe-commits
mailing list