[llvm] [SandboxIR][Tracker] Track eraseFromParent() (PR #99431)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 10:03:37 PDT 2024
================
@@ -41,6 +41,62 @@ Tracker::~Tracker() {
assert(Changes.empty() && "You must accept or revert changes!");
}
+EraseFromParent::EraseFromParent(std::unique_ptr<sandboxir::Value> &&ErasedIPtr,
+ Tracker &Tracker)
+ : IRChangeBase(Tracker), ErasedIPtr(std::move(ErasedIPtr)) {
+ auto *I = cast<Instruction>(this->ErasedIPtr.get());
+ auto LLVMInstrs = I->getLLVMInstrs();
+ // Iterate in reverse program order.
+ for (auto *LLVMI : reverse(LLVMInstrs)) {
+ SmallVector<InstrData::OpData> OpDataVec;
+ for (auto [OpNum, Use] : enumerate(LLVMI->operands()))
+ OpDataVec.push_back({Use.get(), static_cast<unsigned>(OpNum)});
+ InstrData.push_back({OpDataVec, LLVMI});
+ }
+#ifndef NDEBUG
----------------
aeubanks wrote:
no need for `ifdef NDEBUG`, the code should optimize away in a non-asserts build. unsure if need to `[[maybe_unused]]` `Idx`
https://github.com/llvm/llvm-project/pull/99431
More information about the llvm-commits
mailing list