Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
//===----------------------------------------------------------------------===//
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CIR/IR/try-catch.cir
Original file line number Diff line number Diff line change
Expand Up @@ -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: }

}