https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/170042
>From 89ac10b9b847f0ef3f3befaa2c621e21f190ca64 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Sun, 30 Nov 2025 17:57:21 +0100 Subject: [PATCH 1/2] [CIR] Add SCF ResumeOp --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 30 ++++++++++++++++++++ clang/test/CIR/IR/try-catch.cir | 22 ++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index ae199f35cb10e..071341a43a019 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_SCFResumeOp : CIR_Op<"scf.resume", [ + ReturnLike, Terminator +]> { + let summary = "Resumes execution after not catching exceptions"; + let description = [{ + The `cir.scf.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.scf.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..44263345caee3 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 dso_local @empty_try_block_with_catch_unwind_contains_resume() { + cir.scope { + cir.try { + cir.yield + } unwind { + cir.scf.resume + } + } + cir.return +} + +// CHECK: cir.func dso_local @empty_try_block_with_catch_unwind_contains_resume() { +// CHECK: cir.scope { +// CHECK: cir.try { +// CHECK: cir.yield +// CHECK: } unwind { +// CHECK: cir.scf.resume +// CHECK: } +// CHECK: } +// CHECK: cir.return +// CHECK: } + } >From 767aed96e8d260d1523f136dbfbd01c7a3c6482e Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Thu, 4 Dec 2025 19:48:19 +0100 Subject: [PATCH 2/2] Address code review comments --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 8 ++++---- clang/test/CIR/IR/try-catch.cir | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 071341a43a019..295714993d1d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -902,12 +902,12 @@ def CIR_ContinueOp : CIR_Op<"continue", [Terminator]> { // Resume //===----------------------------------------------------------------------===// -def CIR_SCFResumeOp : CIR_Op<"scf.resume", [ - ReturnLike, Terminator +def CIR_ResumeOp : CIR_Op<"resume", [ + ReturnLike, Terminator, HasParent<"cir::TryOp"> ]> { let summary = "Resumes execution after not catching exceptions"; let description = [{ - The `cir.scf.resume` operation handles an uncaught exception scenario. + 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). @@ -919,7 +919,7 @@ def CIR_SCFResumeOp : CIR_Op<"scf.resume", [ cir.try { cir.yield } unwind { - cir.scf.resume + cir.resume } ``` }]; diff --git a/clang/test/CIR/IR/try-catch.cir b/clang/test/CIR/IR/try-catch.cir index 44263345caee3..8ffce067ba043 100644 --- a/clang/test/CIR/IR/try-catch.cir +++ b/clang/test/CIR/IR/try-catch.cir @@ -81,23 +81,23 @@ cir.func dso_local @empty_try_block_with_catch_ist() { // CHECK: cir.return // CHECK: } -cir.func dso_local @empty_try_block_with_catch_unwind_contains_resume() { +cir.func @empty_try_block_with_catch_unwind_contains_resume() { cir.scope { cir.try { cir.yield } unwind { - cir.scf.resume + cir.resume } } cir.return } -// CHECK: cir.func dso_local @empty_try_block_with_catch_unwind_contains_resume() { +// CHECK: cir.func @empty_try_block_with_catch_unwind_contains_resume() { // CHECK: cir.scope { // CHECK: cir.try { // CHECK: cir.yield // CHECK: } unwind { -// CHECK: cir.scf.resume +// CHECK: cir.resume // CHECK: } // CHECK: } // CHECK: cir.return _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
