Skip to content

Commit 15c3bac

Browse files
committed
[CIR] implemented codegen for CIR longjmp op
1 parent 0b3c462 commit 15c3bac

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,8 +1963,16 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
19631963
cir::EhSetjmpOp::create(builder, loc, castBuf, /*is_builtin=*/true);
19641964
return RValue::get(op);
19651965
}
1966-
case Builtin::BI__builtin_longjmp:
1967-
llvm_unreachable("BI__builtin_longjmp NYI");
1966+
case Builtin::BI__builtin_longjmp: {
1967+
Address buf = emitPointerWithAlignment(E->getArg(0));
1968+
mlir::Location loc = getLoc(E->getExprLoc());
1969+
1970+
cir::PointerType ppTy = builder.getPointerTo(builder.getVoidPtrTy());
1971+
mlir::Value castBuf = builder.createBitcast(buf.getPointer(), ppTy);
1972+
cir::EhLongjmpOp::create(builder, loc, castBuf);
1973+
builder.create<cir::UnreachableOp>(loc);
1974+
return RValue::get(nullptr);
1975+
}
19681976
case Builtin::BI__builtin_launder: {
19691977
const clang::Expr *arg = E->getArg(0);
19701978
clang::QualType argTy = arg->getType()->getPointeeType();

0 commit comments

Comments
 (0)