From c9be54c9f370a2d0f2d31d201bb0370adb506a39 Mon Sep 17 00:00:00 2001 From: usuyus Date: Wed, 6 Aug 2025 16:40:57 +0100 Subject: [PATCH] clean up diff --- llvm/include/llvm/IR/Intrinsics.td | 3 +++ .../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index e0fd727607ce6..162d69b8898f7 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -1046,6 +1046,9 @@ def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>; def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>; +def int_eh_ocaml_try : Intrinsic<[llvm_i32_ty], []>; +def int_eh_ocaml_touch : Intrinsic<[], [llvm_ptr_ty], [IntrHasSideEffects]>; + //===---------------- Generic Variable Attribute Intrinsics----------------===// // def int_var_annotation : DefaultAttrsIntrinsic< diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 0bdfdac6a65f1..7e51b69c4050c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6287,6 +6287,20 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, DAG.setRoot(DAG.getNode(ISD::EH_SJLJ_SETUP_DISPATCH, sdl, MVT::Other, getRoot())); return; + case Intrinsic::eh_ocaml_try: { + // Always returns 0. To be used with the "returns twice" attribute. + // Acts as a black box value to use to branch either to the try block or + // handler to give an idea of how control flow would look like to LLVM. + // (It would be nice to mark the attribute directly in LLVM, but putting + // it in the IR manually suffices for now.) + setValue(&I, DAG.getConstant(0, sdl, MVT::i32)); + return; + } + case Intrinsic::eh_ocaml_touch: { + // A no-op that makes sure its alloca'd pointer argument doesn't get + // lowered to a temporary and stays on the stack. + return; + } case Intrinsic::masked_gather: visitMaskedGather(I); return;