LLVM 20.0.0git
Tracker.h
Go to the documentation of this file.
1//===- Tracker.h ------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is the component of SandboxIR that tracks all changes made to its
10// state, such that we can revert the state when needed.
11//
12// Tracking changes
13// ----------------
14// The user needs to call `Tracker::save()` to enable tracking changes
15// made to SandboxIR. From that point on, any change made to SandboxIR, will
16// automatically create a change tracking object and register it with the
17// tracker. IR-change objects are subclasses of `IRChangeBase` and get
18// registered with the `Tracker::track()` function. The change objects
19// are saved in the order they are registered with the tracker and are stored in
20// the `Tracker::Changes` vector. All of this is done transparently to
21// the user.
22//
23// Reverting changes
24// -----------------
25// Calling `Tracker::revert()` will restore the state saved when
26// `Tracker::save()` was called. Internally this goes through the
27// change objects in `Tracker::Changes` in reverse order, calling their
28// `IRChangeBase::revert()` function one by one.
29//
30// Accepting changes
31// -----------------
32// The user needs to either revert or accept changes before the tracker object
33// is destroyed. This is enforced in the tracker's destructor.
34// This is the job of `Tracker::accept()`. Internally this will go
35// through the change objects in `Tracker::Changes` in order, calling
36// `IRChangeBase::accept()`.
37//
38//===----------------------------------------------------------------------===//
39
40#ifndef LLVM_SANDBOXIR_TRACKER_H
41#define LLVM_SANDBOXIR_TRACKER_H
42
46#include "llvm/IR/IRBuilder.h"
47#include "llvm/IR/Instruction.h"
48#include "llvm/SandboxIR/Use.h"
49#include "llvm/Support/Debug.h"
50#include <memory>
51
52namespace llvm::sandboxir {
53
54class BasicBlock;
55class CallBrInst;
56class LoadInst;
57class StoreInst;
58class Instruction;
59class Tracker;
60class AllocaInst;
61class CatchSwitchInst;
62class SwitchInst;
63class ConstantInt;
64class ShuffleVectorInst;
65class CmpInst;
66class GlobalVariable;
67
68#ifndef NDEBUG
69
70/// A class that saves hashes and textual IR snapshots of functions in a
71/// SandboxIR Context, and does hash comparison when `expectNoDiff` is called.
72/// If hashes differ, it prints textual IR for both old and new versions to
73/// aid debugging.
74///
75/// This is used as an additional debug check when reverting changes to
76/// SandboxIR, to verify the reverted state matches the initial state.
78 Context &Ctx;
79
80 // A snapshot of textual IR for a function, with a hash for quick comparison.
81 struct FunctionSnapshot {
83 std::string TextualIR;
84 };
85
86 // A snapshot for each llvm::Function found in every module in the SandboxIR
87 // Context. In practice there will always be one module, but sandbox IR
88 // save/restore ops work at the Context level, so we must take the full state
89 // into account.
91
92 ContextSnapshot OrigContextSnapshot;
93
94 // Dumps to a string the textual IR for a single Function.
95 std::string dumpIR(const llvm::Function &F) const;
96
97 // Returns a snapshot of all the modules in the sandbox IR context.
98 ContextSnapshot takeSnapshot() const;
99
100 // Compares two snapshots and returns true if they differ.
101 bool diff(const ContextSnapshot &Orig, const ContextSnapshot &Curr) const;
102
103public:
104 IRSnapshotChecker(Context &Ctx) : Ctx(Ctx) {}
105
106 /// Saves a snapshot of the current state. If there was any previous snapshot,
107 /// it will be replaced with the new one.
108 void save();
109
110 /// Checks current state against saved state, crashes if different.
111 void expectNoDiff();
112};
113
114#endif // NDEBUG
115
116/// The base class for IR Change classes.
118protected:
119 friend class Tracker; // For Parent.
120
121public:
122 /// This runs when changes get reverted.
123 virtual void revert(Tracker &Tracker) = 0;
124 /// This runs when changes get accepted.
125 virtual void accept() = 0;
126 virtual ~IRChangeBase() = default;
127#ifndef NDEBUG
128 virtual void dump(raw_ostream &OS) const = 0;
129 LLVM_DUMP_METHOD virtual void dump() const = 0;
131 C.dump(OS);
132 return OS;
133 }
134#endif
135};
136
137/// Tracks the change of the source Value of a sandboxir::Use.
138class UseSet : public IRChangeBase {
139 Use U;
140 Value *OrigV = nullptr;
141
142public:
143 UseSet(const Use &U) : U(U), OrigV(U.get()) {}
144 void revert(Tracker &Tracker) final { U.set(OrigV); }
145 void accept() final {}
146#ifndef NDEBUG
147 void dump(raw_ostream &OS) const final { OS << "UseSet"; }
148 LLVM_DUMP_METHOD void dump() const final;
149#endif
150};
151
153 PHINode *PHI;
154 unsigned RemovedIdx;
155 Value *RemovedV;
156 BasicBlock *RemovedBB;
157
158public:
159 PHIRemoveIncoming(PHINode *PHI, unsigned RemovedIdx);
160 void revert(Tracker &Tracker) final;
161 void accept() final {}
162#ifndef NDEBUG
163 void dump(raw_ostream &OS) const final { OS << "PHISetIncoming"; }
164 LLVM_DUMP_METHOD void dump() const final;
165#endif
166};
167
169 PHINode *PHI;
170 unsigned Idx;
171
172public:
174 void revert(Tracker &Tracker) final;
175 void accept() final {}
176#ifndef NDEBUG
177 void dump(raw_ostream &OS) const final { OS << "PHISetIncoming"; }
178 LLVM_DUMP_METHOD void dump() const final;
179#endif
180};
181
183 CmpInst *Cmp;
184
185public:
187 void revert(Tracker &Tracker) final;
188 void accept() final {}
189#ifndef NDEBUG
190 void dump(raw_ostream &OS) const final { OS << "CmpSwapOperands"; }
191 LLVM_DUMP_METHOD void dump() const final;
192#endif
193};
194
195/// Tracks swapping a Use with another Use.
196class UseSwap : public IRChangeBase {
197 Use ThisUse;
198 Use OtherUse;
199
200public:
201 UseSwap(const Use &ThisUse, const Use &OtherUse)
202 : ThisUse(ThisUse), OtherUse(OtherUse) {
203 assert(ThisUse.getUser() == OtherUse.getUser() && "Expected same user!");
204 }
205 void revert(Tracker &Tracker) final { ThisUse.swap(OtherUse); }
206 void accept() final {}
207#ifndef NDEBUG
208 void dump(raw_ostream &OS) const final { OS << "UseSwap"; }
209 LLVM_DUMP_METHOD void dump() const final;
210#endif
211};
212
214 /// Contains all the data we need to restore an "erased" (i.e., detached)
215 /// instruction: the instruction itself and its operands in order.
216 struct InstrAndOperands {
217 /// The operands that got dropped.
219 /// The instruction that got "erased".
220 llvm::Instruction *LLVMI;
221 };
222 /// The instruction data is in reverse program order, which helps create the
223 /// original program order during revert().
225 /// This is either the next Instruction in the stream, or the parent
226 /// BasicBlock if at the end of the BB.
228 /// We take ownership of the "erased" instruction.
229 std::unique_ptr<sandboxir::Value> ErasedIPtr;
230
231public:
232 EraseFromParent(std::unique_ptr<sandboxir::Value> &&IPtr);
233 void revert(Tracker &Tracker) final;
234 void accept() final;
235#ifndef NDEBUG
236 void dump(raw_ostream &OS) const final { OS << "EraseFromParent"; }
237 LLVM_DUMP_METHOD void dump() const final;
239 C.dump(OS);
240 return OS;
241 }
242#endif
243};
244
246 /// The instruction that is about to get removed.
247 Instruction *RemovedI = nullptr;
248 /// This is either the next instr, or the parent BB if at the end of the BB.
250
251public:
252 RemoveFromParent(Instruction *RemovedI);
253 void revert(Tracker &Tracker) final;
254 void accept() final {};
255 Instruction *getInstruction() const { return RemovedI; }
256#ifndef NDEBUG
257 void dump(raw_ostream &OS) const final { OS << "RemoveFromParent"; }
258 LLVM_DUMP_METHOD void dump() const final;
259#endif // NDEBUG
260};
261
262/// This class can be used for tracking most instruction setters.
263/// The two template arguments are:
264/// - GetterFn: The getter member function pointer (e.g., `&Foo::get`)
265/// - SetterFn: The setter member function pointer (e.g., `&Foo::set`)
266/// Upon construction, it saves a copy of the original value by calling the
267/// getter function. Revert sets the value back to the one saved, using the
268/// setter function provided.
269///
270/// Example:
271/// Tracker.track(std::make_unique<
272/// GenericSetter<&FooInst::get, &FooInst::set>>(I, Tracker));
273///
274template <auto GetterFn, auto SetterFn>
275class GenericSetter final : public IRChangeBase {
276 /// Traits for getting the class type from GetterFn type.
277 template <typename> struct GetClassTypeFromGetter;
278 template <typename RetT, typename ClassT>
279 struct GetClassTypeFromGetter<RetT (ClassT::*)() const> {
280 using ClassType = ClassT;
281 };
282 using InstrT = typename GetClassTypeFromGetter<decltype(GetterFn)>::ClassType;
283 using SavedValT = std::invoke_result_t<decltype(GetterFn), InstrT>;
284 InstrT *I;
285 SavedValT OrigVal;
286
287public:
288 GenericSetter(InstrT *I) : I(I), OrigVal((I->*GetterFn)()) {}
289 void revert(Tracker &Tracker) final { (I->*SetterFn)(OrigVal); }
290 void accept() final {}
291#ifndef NDEBUG
292 void dump(raw_ostream &OS) const final { OS << "GenericSetter"; }
294 dump(dbgs());
295 dbgs() << "\n";
296 }
297#endif
298};
299
300/// Similar to GenericSetter but the setters/getters have an index as their
301/// first argument. This is commont in cases like: getOperand(unsigned Idx)
302template <auto GetterFn, auto SetterFn>
303class GenericSetterWithIdx final : public IRChangeBase {
304 /// Helper for getting the class type from the getter
305 template <typename ClassT, typename RetT>
306 static ClassT getClassTypeFromGetter(RetT (ClassT::*Fn)(unsigned) const);
307 template <typename ClassT, typename RetT>
308 static ClassT getClassTypeFromGetter(RetT (ClassT::*Fn)(unsigned));
309
310 using InstrT = decltype(getClassTypeFromGetter(GetterFn));
311 using SavedValT = std::invoke_result_t<decltype(GetterFn), InstrT, unsigned>;
312 InstrT *I;
313 SavedValT OrigVal;
314 unsigned Idx;
315
316public:
317 GenericSetterWithIdx(InstrT *I, unsigned Idx)
318 : I(I), OrigVal((I->*GetterFn)(Idx)), Idx(Idx) {}
319 void revert(Tracker &Tracker) final { (I->*SetterFn)(Idx, OrigVal); }
320 void accept() final {}
321#ifndef NDEBUG
322 void dump(raw_ostream &OS) const final { OS << "GenericSetterWithIdx"; }
324 dump(dbgs());
325 dbgs() << "\n";
326 }
327#endif
328};
329
331 CatchSwitchInst *CSI;
332 unsigned HandlerIdx;
333
334public:
336 void revert(Tracker &Tracker) final;
337 void accept() final {}
338#ifndef NDEBUG
339 void dump(raw_ostream &OS) const final { OS << "CatchSwitchAddHandler"; }
341 dump(dbgs());
342 dbgs() << "\n";
343 }
344#endif // NDEBUG
345};
346
348 SwitchInst *Switch;
349 ConstantInt *Val;
350
351public:
353 : Switch(Switch), Val(Val) {}
354 void revert(Tracker &Tracker) final;
355 void accept() final {}
356#ifndef NDEBUG
357 void dump(raw_ostream &OS) const final { OS << "SwitchAddCase"; }
358 LLVM_DUMP_METHOD void dump() const final;
359#endif // NDEBUG
360};
361
363 SwitchInst *Switch;
364 struct Case {
365 ConstantInt *Val;
366 BasicBlock *Dest;
367 };
368 SmallVector<Case> Cases;
369
370public:
372
373 void revert(Tracker &Tracker) final;
374 void accept() final {}
375#ifndef NDEBUG
376 void dump(raw_ostream &OS) const final { OS << "SwitchRemoveCase"; }
377 LLVM_DUMP_METHOD void dump() const final;
378#endif // NDEBUG
379};
380
381class MoveInstr : public IRChangeBase {
382 /// The instruction that moved.
383 Instruction *MovedI;
384 /// This is either the next instruction in the block, or the parent BB if at
385 /// the end of the BB.
387
388public:
390 void revert(Tracker &Tracker) final;
391 void accept() final {}
392#ifndef NDEBUG
393 void dump(raw_ostream &OS) const final { OS << "MoveInstr"; }
394 LLVM_DUMP_METHOD void dump() const final;
395#endif // NDEBUG
396};
397
398class InsertIntoBB final : public IRChangeBase {
399 Instruction *InsertedI = nullptr;
400
401public:
402 InsertIntoBB(Instruction *InsertedI);
403 void revert(Tracker &Tracker) final;
404 void accept() final {}
405#ifndef NDEBUG
406 void dump(raw_ostream &OS) const final { OS << "InsertIntoBB"; }
407 LLVM_DUMP_METHOD void dump() const final;
408#endif // NDEBUG
409};
410
411class CreateAndInsertInst final : public IRChangeBase {
412 Instruction *NewI = nullptr;
413
414public:
415 CreateAndInsertInst(Instruction *NewI) : NewI(NewI) {}
416 void revert(Tracker &Tracker) final;
417 void accept() final {}
418#ifndef NDEBUG
419 void dump(raw_ostream &OS) const final { OS << "CreateAndInsertInst"; }
420 LLVM_DUMP_METHOD void dump() const final;
421#endif
422};
423
424class ShuffleVectorSetMask final : public IRChangeBase {
426 SmallVector<int, 8> PrevMask;
427
428public:
430 void revert(Tracker &Tracker) final;
431 void accept() final {}
432#ifndef NDEBUG
433 void dump(raw_ostream &OS) const final { OS << "ShuffleVectorSetMask"; }
434 LLVM_DUMP_METHOD void dump() const final;
435#endif
436};
437
438/// The tracker collects all the change objects and implements the main API for
439/// saving / reverting / accepting.
440class Tracker {
441public:
442 enum class TrackerState {
443 Disabled, ///> Tracking is disabled
444 Record, ///> Tracking changes
445 };
446
447private:
448 /// The list of changes that are being tracked.
450 /// The current state of the tracker.
452 Context &Ctx;
453
454#ifndef NDEBUG
455 IRSnapshotChecker SnapshotChecker;
456#endif
457
458public:
459#ifndef NDEBUG
460 /// Helps catch bugs where we are creating new change objects while in the
461 /// middle of creating other change objects.
463#endif // NDEBUG
464
465 explicit Tracker(Context &Ctx)
466 : Ctx(Ctx)
467#ifndef NDEBUG
468 ,
469 SnapshotChecker(Ctx)
470#endif
471 {
472 }
473
474 ~Tracker();
475 Context &getContext() const { return Ctx; }
476 /// Record \p Change and take ownership. This is the main function used to
477 /// track Sandbox IR changes.
478 void track(std::unique_ptr<IRChangeBase> &&Change) {
479 assert(State == TrackerState::Record && "The tracker should be tracking!");
480#ifndef NDEBUG
482 "We are in the middle of creating another change!");
483 if (isTracking())
485#endif // NDEBUG
486 Changes.push_back(std::move(Change));
487
488#ifndef NDEBUG
490#endif
491 }
492 /// A convenience wrapper for `track()` that constructs and tracks the Change
493 /// object if tracking is enabled. \Returns true if tracking is enabled.
494 template <typename ChangeT, typename... ArgsT>
495 bool emplaceIfTracking(ArgsT... Args) {
496 if (!isTracking())
497 return false;
498 track(std::make_unique<ChangeT>(Args...));
499 return true;
500 }
501 /// \Returns true if the tracker is recording changes.
502 bool isTracking() const { return State == TrackerState::Record; }
503 /// \Returns the current state of the tracker.
504 TrackerState getState() const { return State; }
505 /// Turns on IR tracking.
506 void save();
507 /// Stops tracking and accept changes.
508 void accept();
509 /// Stops tracking and reverts to saved state.
510 void revert();
511
512#ifndef NDEBUG
513 void dump(raw_ostream &OS) const;
514 LLVM_DUMP_METHOD void dump() const;
516 Tracker.dump(OS);
517 return OS;
518 }
519#endif // NDEBUG
520};
521
522} // namespace llvm::sandboxir
523
524#endif // LLVM_SANDBOXIR_TRACKER_H
aarch64 promote const
Rewrite undef for PHI
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:622
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
mir Rename Register Operands
This file defines the PointerUnion class, which is a discriminated union of pointer types.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallVector class.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:118
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
Contains a list of sandboxir::Instruction's.
Definition: BasicBlock.h:67
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.h:340
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:229
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:337
void dump(raw_ostream &OS) const final
Definition: Tracker.h:339
void dump(raw_ostream &OS) const final
Definition: Tracker.h:190
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:188
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:333
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:335
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:311
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:417
CreateAndInsertInst(Instruction *NewI)
Definition: Tracker.h:415
void dump(raw_ostream &OS) const final
Definition: Tracker.h:419
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:308
void dump(raw_ostream &OS) const final
Definition: Tracker.h:236
void accept() final
This runs when changes get accepted.
Definition: Tracker.cpp:169
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:197
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:174
Similar to GenericSetter but the setters/getters have an index as their first argument.
Definition: Tracker.h:303
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.h:319
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.h:323
void dump(raw_ostream &OS) const final
Definition: Tracker.h:322
GenericSetterWithIdx(InstrT *I, unsigned Idx)
Definition: Tracker.h:317
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:320
This class can be used for tracking most instruction setters.
Definition: Tracker.h:275
void dump(raw_ostream &OS) const final
Definition: Tracker.h:292
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:290
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.h:289
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.h:293
The base class for IR Change classes.
Definition: Tracker.h:117
virtual LLVM_DUMP_METHOD void dump() const =0
virtual void revert(Tracker &Tracker)=0
This runs when changes get reverted.
friend raw_ostream & operator<<(raw_ostream &OS, const IRChangeBase &C)
Definition: Tracker.h:130
virtual ~IRChangeBase()=default
virtual void accept()=0
This runs when changes get accepted.
virtual void dump(raw_ostream &OS) const =0
A class that saves hashes and textual IR snapshots of functions in a SandboxIR Context,...
Definition: Tracker.h:77
void expectNoDiff()
Checks current state against saved state, crashes if different.
Definition: Tracker.cpp:74
void save()
Saves a snapshot of the current state.
Definition: Tracker.cpp:72
void dump(raw_ostream &OS) const final
Definition: Tracker.h:406
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:302
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:404
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:297
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Definition: Instruction.h:42
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:291
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:281
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:391
void dump(raw_ostream &OS) const final
Definition: Tracker.h:393
void dump(raw_ostream &OS) const final
Definition: Tracker.h:177
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:132
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:175
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:135
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:161
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:123
void dump(raw_ostream &OS) const final
Definition: Tracker.h:163
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:99
void dump(raw_ostream &OS) const final
Definition: Tracker.h:257
Instruction * getInstruction() const
Definition: Tracker.h:255
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:210
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:254
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:220
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:325
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:431
void dump(raw_ostream &OS) const final
Definition: Tracker.h:433
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:320
SwitchAddCase(SwitchInst *Switch, ConstantInt *Val)
Definition: Tracker.h:352
void dump(raw_ostream &OS) const final
Definition: Tracker.h:357
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:262
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:268
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:355
void dump(raw_ostream &OS) const final
Definition: Tracker.h:376
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:256
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:374
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.cpp:241
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
Definition: Tracker.h:440
@ Record
ā€¨Tracking is disabled
void revert()
Stops tracking and reverts to saved state.
Definition: Tracker.cpp:348
TrackerState getState() const
\Returns the current state of the tracker.
Definition: Tracker.h:504
friend raw_ostream & operator<<(raw_ostream &OS, const Tracker &Tracker)
Definition: Tracker.h:515
void dump(raw_ostream &OS) const
Definition: Tracker.cpp:368
bool isTracking() const
\Returns true if the tracker is recording changes.
Definition: Tracker.h:502
void save()
Turns on IR tracking.
Definition: Tracker.cpp:341
Tracker(Context &Ctx)
Definition: Tracker.h:465
void track(std::unique_ptr< IRChangeBase > &&Change)
Record Change and take ownership.
Definition: Tracker.h:478
bool InMiddleOfCreatingChange
Helps catch bugs where we are creating new change objects while in the middle of creating other chang...
Definition: Tracker.h:462
Context & getContext() const
Definition: Tracker.h:475
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Definition: Tracker.h:495
void accept()
Stops tracking and accept changes.
Definition: Tracker.cpp:359
LLVM_DUMP_METHOD void dump() const
Definition: Tracker.cpp:375
Tracks the change of the source Value of a sandboxir::Use.
Definition: Tracker.h:138
UseSet(const Use &U)
Definition: Tracker.h:143
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.h:144
void dump(raw_ostream &OS) const final
Definition: Tracker.h:147
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:145
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:82
Tracks swapping a Use with another Use.
Definition: Tracker.h:196
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Definition: Tracker.h:205
LLVM_DUMP_METHOD void dump() const final
Definition: Tracker.cpp:87
void accept() final
This runs when changes get accepted.
Definition: Tracker.h:206
void dump(raw_ostream &OS) const final
Definition: Tracker.h:208
UseSwap(const Use &ThisUse, const Use &OtherUse)
Definition: Tracker.h:201
Represents a Def-use/Use-def edge in SandboxIR.
Definition: Use.h:32
void swap(Use &OtherUse)
Definition: Use.cpp:24
class User * getUser() const
Definition: Use.h:54
A SandboxIR Value has users. This is the base class.
Definition: Value.h:63
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
#define NDEBUG
Definition: regutils.h:48