[clang] [CIR] Handle throwing calls inside EH cleanup (PR #188341)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 06:54:17 PDT 2026


================
@@ -7037,6 +7037,46 @@ def CIR_EhInitiateOp : CIR_Op<"eh.initiate"> {
   let hasLLVMLowering = false;
 }
 
+//===----------------------------------------------------------------------===//
+// Flattened EH Operations: EhTerminateOp
+//===----------------------------------------------------------------------===//
+
+def CIR_EhTerminateOp : CIR_Op<"eh.terminate", [
+  Terminator
+]> {
+  let summary = "Terminate due to exception thrown during cleanup";
+  let description = [{
+    `cir.eh.terminate` terminates program execution when an exception is thrown
+    while executing cleanup code during exception unwinding. The C++ standard
+    requires that `std::terminate()` be called in this scenario.
+
+    This operation takes an `!cir.eh_token` from a `cir.eh.initiate` operation
+    and acts as a terminator. It is produced during CFG flattening when throwing
+    calls are found in EH cleanup regions.
+
+    During EH ABI lowering, this is replaced with target-specific termination
+    code. For the Itanium ABI, the `cir.eh.initiate` is lowered to
----------------
erichkeane wrote:

The `cir.eh.initiate` is both lowered to `inflight_exception` and `becomes a call to...`.  Is that not weirdly worded? 

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


More information about the cfe-commits mailing list