[clang] [CIR] Add pass to fold empty branches (PR #239417)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 15:47:32 PST 2026


================
@@ -29,6 +29,22 @@ def CIRCanonicalize : Pass<"cir-canonicalize"> {
   let dependentDialects = ["cir::CIRDialect"];
 }
 
+def CIRFoldEmptyBranches : Pass<"cir-fold-empty-branches"> {
+  let summary = "Removes blocks that contain only an unconditional branch";
+  let description = [{
+    Removes every non-entry block that has no arguments, contains only a
----------------
andykaylor wrote:

I think that would require a significant redesign of the FlattenCFG pass. At a very high level, we're converting regions to blocks and replacing terminators with branch instructions, so falling out of a bunch of nested regions ends up as a chain of branches through empty blocks.

https://github.com/llvm/llvm-project/pull/239417


More information about the cfe-commits mailing list