Author: Amr Hesham Date: 2025-12-05T19:32:53+01:00 New Revision: 3de977cdde85847b89f443ad13a0d591e87e8871
URL: https://github.com/llvm/llvm-project/commit/3de977cdde85847b89f443ad13a0d591e87e8871 DIFF: https://github.com/llvm/llvm-project/commit/3de977cdde85847b89f443ad13a0d591e87e8871.diff LOG: [CIR] Add structured ResumeOp (#170042) Add SCF Resume op to be used before the CFG flattening pass Issue https://github.com/llvm/llvm-project/issues/154992 Added: Modified: clang/include/clang/CIR/Dialect/IR/CIROps.td clang/test/CIR/IR/try-catch.cir Removed: ################################################################################ diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index d720b97b2e378..80c184e4f478c 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -898,6 +898,36 @@ def CIR_ContinueOp : CIR_Op<"continue", [Terminator]> { let hasLLVMLowering = false; } +//===----------------------------------------------------------------------===// +// Resume +//===----------------------------------------------------------------------===// + +def CIR_ResumeOp : CIR_Op<"resume", [ + ReturnLike, Terminator, HasParent<"cir::TryOp"> +]> { + let summary = "Resumes execution after not catching exceptions"; + let description = [{ + The `cir.resume` operation handles an uncaught exception scenario. + + Used as the terminator of a `CatchUnwind` region of `cir.try`, where it + does not receive any arguments (implied from the `cir.try` scope). + + This operation is used only before the CFG flatterning pass. + + Examples: + ```mlir + cir.try { + cir.yield + } unwind { + cir.resume + } + ``` + }]; + + let assemblyFormat = "attr-dict"; + let hasLLVMLowering = false; +} + //===----------------------------------------------------------------------===// // ScopeOp //===----------------------------------------------------------------------===// diff --git a/clang/test/CIR/IR/try-catch.cir b/clang/test/CIR/IR/try-catch.cir index 7becd0b559f5e..8ffce067ba043 100644 --- a/clang/test/CIR/IR/try-catch.cir +++ b/clang/test/CIR/IR/try-catch.cir @@ -81,4 +81,26 @@ cir.func dso_local @empty_try_block_with_catch_ist() { // CHECK: cir.return // CHECK: } +cir.func @empty_try_block_with_catch_unwind_contains_resume() { + cir.scope { + cir.try { + cir.yield + } unwind { + cir.resume + } + } + cir.return +} + +// CHECK: cir.func @empty_try_block_with_catch_unwind_contains_resume() { +// CHECK: cir.scope { +// CHECK: cir.try { +// CHECK: cir.yield +// CHECK: } unwind { +// CHECK: cir.resume +// CHECK: } +// CHECK: } +// CHECK: cir.return +// CHECK: } + } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
