[clang] [CIR] Add CIRGen for cir.unreachable and cir.trap (PR #151363)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 31 09:20:51 PDT 2025


================
@@ -269,6 +270,22 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
   case Builtin::BI__builtin_rotateright32:
   case Builtin::BI__builtin_rotateright64:
     return emitRotate(e, /*isRotateLeft=*/false);
+
+  case Builtin::BI__builtin_trap: {
+    builder.create<cir::TrapOp>(loc);
+    // Note that cir.trap is a terminator so we need to start a new dummy block
+    // to preserve the builder's insertion point.
+    builder.createBlock(builder.getBlock()->getParent());
----------------
Lancern wrote:

> Maybe we could put builder.createBlock in emitUnreachable and emitTrap though.

I updated code like this.

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


More information about the cfe-commits mailing list