[llvm] [SandboxIR] IR Tracker (PR #99238)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 20:42:27 PDT 2024
================
@@ -0,0 +1,84 @@
+//===- SandboxIRTracker.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/SandboxIR/SandboxIRTracker.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/SandboxIR/SandboxIR.h"
+#include <sstream>
+
+using namespace llvm::sandboxir;
+
+IRChangeBase::IRChangeBase(TrackID ID, SandboxIRTracker &Parent)
+ : ID(ID), Parent(Parent) {
+#ifndef NDEBUG
+ Idx = Parent.size();
+
+ assert(!Parent.InMiddleOfCreatingChange &&
+ "We are in the middle of creating another change!");
+ if (Parent.tracking())
+ Parent.InMiddleOfCreatingChange = true;
+#endif // NDEBUG
+}
+
+#ifndef NDEBUG
+void UseSet::dump() const {
+ dump(dbgs());
+ dbgs() << "\n";
+}
+#endif // NDEBUG
+
+SandboxIRTracker::~SandboxIRTracker() {
+ assert(Changes.empty() && "You must accept or revert changes!");
+}
+
+void SandboxIRTracker::track(std::unique_ptr<IRChangeBase> &&Change) {
+#ifndef NDEBUG
----------------
aeubanks wrote:
no need for `ifndef NDEBUG`
https://github.com/llvm/llvm-project/pull/99238
More information about the llvm-commits
mailing list