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