[clang] [CIR][NFC] Use CleanupKindAttr predicates in FlattenCFG (PR #221234)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 09:47:24 PDT 2026
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/221234
>From cff30e75b271c74c0d61589e221459e33ec51f57 Mon Sep 17 00:00:00 2001
From: Henrich Lauko <hlauko at nvidia.com>
Date: Fri, 4 Sep 2026 14:28:53 +0000
Subject: [PATCH] [CIR][NFC] Use CleanupKindAttr predicates in FlattenCFG
flattenCleanup still tests the cleanup kind with raw enum comparisons against
Normal, EH and All. CleanupKindAttr already declares isNormal() and isEH() with
exactly those meanings, and the rest of FlattenCFG, including the match method
that feeds flattenCleanup, already uses them, so use the predicates here too.
CleanupScopeOp::getSuccessorRegions depends on this same invariant. Stating it
in one place means a later change to the kinds cannot leave the copies
disagreeing.
---
clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp b/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
index 4005124a054ac..2787b57adad6e 100644
--- a/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
@@ -1449,11 +1449,9 @@ class CIRCleanupScopeOpFlattening
llvm::SmallVectorImpl<cir::ResumeOp> &resumeOpsToChain,
mlir::PatternRewriter &rewriter) const {
mlir::Location loc = cleanupOp.getLoc();
- cir::CleanupKind cleanupKind = cleanupOp.getCleanupKind();
- bool hasNormalCleanup = cleanupKind == cir::CleanupKind::Normal ||
- cleanupKind == cir::CleanupKind::All;
- bool hasEHCleanup = cleanupKind == cir::CleanupKind::EH ||
- cleanupKind == cir::CleanupKind::All;
+ cir::CleanupKindAttr cleanupKind = cleanupOp.getCleanupKindAttr();
+ bool hasNormalCleanup = cleanupKind.isNormal();
+ bool hasEHCleanup = cleanupKind.isEH();
bool isMultiExit = exits.size() > 1;
// If every exit from the body is a musttail return, nothing reaches the
More information about the cfe-commits
mailing list