[llvm] [SandboxVec][VecUtils] Introduce DeadInstrMorgue (PR #221482)

Anshil Gandhi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 14:47:36 PDT 2026


================
@@ -403,6 +403,40 @@ class VecUtils {
     }
   };
 
+  /// Utility class to collect and erase dead instructions.
+  class DeadInstructionMorgue {
+  public:
+    DeadInstructionMorgue() = default;
+    DeadInstructionMorgue(const DeadInstructionMorgue &) = delete;
+
+    /// After we create vectors for groups of instructions, the original
+    /// instructions are potentially dead and may need to be removed. This
+    /// function helps collect these instructions (along with the pointer
+    /// operands for loads/stores) so that they can be cleaned up later.
+    void collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl);
+
+    /// Erases all dead instructions from the dead instruction candidates
+    /// collected during vectorization. Also clear the DeadInstrCandidates.
+    void tryEraseDeadInstrs();
+
+#ifndef NDEBUG
+    void print(raw_ostream &OS) const {
+      OS << "DeadInstrCandidates: [\n";
+      for (auto *C : DeadInstrCandidates) {
+        OS << *C << ",\n";
----------------
gandhi56 wrote:

1. No it does not. I think you are thinking of `I->dump()`. I need to add a newline here.
2. Sure
3. Removed the brackets.

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


More information about the llvm-commits mailing list