[llvm] [SandboxIR][Tracker] Track eraseFromParent() (PR #99431)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 22:28:52 PDT 2024


================
@@ -99,6 +99,46 @@ class UseSet : public IRChangeBase {
 #endif
 };
 
+class EraseFromParent : public IRChangeBase {
+  /// Contains all the data we need to restore an "erased" (i.e., detached)
+  /// instruction: the instruction itself and the operands data.
+  struct InstrData {
+    /// The operand and the corresponding operand number.
+    struct OpData {
+      llvm::Value *Op;
+      unsigned long OpNum;
+    };
+    /// The operands that got dropped.
+    SmallVector<OpData> OpDataVec;
+    /// The instruction that got "erased".
+    llvm::Instruction *LLVMI;
+  };
+  /// The instruction data is in revere program order, which helps create the
+  /// original program order during revert().
+  SmallVector<InstrData> InstrData;
+  /// This is either the next Instruction in the stream, or the parent
+  /// BasicBlock if at the end of the BB.
+  llvm::Value *NextLLVMIOrBB;
----------------
tschuett wrote:

I would have used a `std::variant` to make it absolutely clear that it is either or and the compiler verifies that invariant.

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


More information about the llvm-commits mailing list