[llvm] [SandboxIR] Implement LandingPadInst (PR #106116)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 13:33:55 PDT 2024


================
@@ -1888,6 +1890,50 @@ class CallBrInst final : public CallBase {
   }
 };
 
+class LandingPadInst : public SingleLLVMInstructionImpl<llvm::LandingPadInst> {
+  LandingPadInst(llvm::LandingPadInst *LP, Context &Ctx)
+      : SingleLLVMInstructionImpl(ClassID::LandingPad, Opcode::LandingPad, LP,
+                                  Ctx) {}
+  friend class Context; // For constructor.
+
+public:
+  static LandingPadInst *create(Type *RetTy, unsigned NumReservedClauses,
+                                BBIterator WhereIt, BasicBlock *WhereBB,
+                                Context &Ctx, const Twine &Name = "");
+  /// Return 'true' if this landingpad instruction is a
+  /// cleanup. I.e., it should be run when unwinding even if its landing pad
+  /// doesn't catch the exception.
+  bool isCleanup() const {
+    return cast<llvm::LandingPadInst>(Val)->isCleanup();
+  }
+  /// Indicate that this landingpad instruction is a cleanup.
+  void setCleanup(bool V);
+
+  // TODO: We are not implementing addClause() because we have no way to revert
+  // it for now.
----------------
vporpo wrote:

Yes, this could be added later on, if someone really needs it. It would require some changes in LLVM IR because currently there is no API that would allow us to revert it.

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


More information about the llvm-commits mailing list