|
LLVM 23.0.0git
|
The tracker collects all the change objects and implements the main API for saving / reverting / accepting. More...
#include "llvm/SandboxIR/Tracker.h"
Public Types | |
| enum class | TrackerState { Disabled , Record , Reverting } |
Public Member Functions | |
| Tracker (Context &Ctx) | |
| LLVM_ABI | ~Tracker () |
| Context & | getContext () const |
| bool | empty () const |
| \Returns true if there are no changes tracked. | |
| void | track (std::unique_ptr< IRChangeBase > &&Change) |
Record Change and take ownership. | |
| template<typename ChangeT, typename... ArgsT> | |
| bool | emplaceIfTracking (ArgsT... Args) |
| A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled. | |
| bool | isTracking () const |
| \Returns true if the tracker is recording changes. | |
| TrackerState | getState () const |
| \Returns the current state of the tracker. | |
| LLVM_ABI void | save () |
| Turns on IR tracking. | |
| LLVM_ABI void | accept (bool AcceptAll=false) |
| Stops tracking and accept changes. | |
| LLVM_ABI void | revert (bool RevertAll=false) |
| Stops tracking and reverts to saved state. | |
| unsigned | nestingDepth () const |
| void | dump (raw_ostream &OS) const |
| LLVM_DUMP_METHOD void | dump () const |
Public Attributes | |
| bool | InMiddleOfCreatingChange = false |
| Helps catch bugs where we are creating new change objects while in the middle of creating other change objects. | |
Friends | |
| raw_ostream & | operator<< (raw_ostream &OS, const Tracker &Tracker) |
The tracker collects all the change objects and implements the main API for saving / reverting / accepting.
|
strong |
|
inlineexplicit |
Definition at line 480 of file Tracker.h.
Referenced by operator<<.
| Tracker::~Tracker | ( | ) |
Definition at line 131 of file Tracker.cpp.
References assert().
| void Tracker::accept | ( | bool | AcceptAll = false | ) |
Stops tracking and accept changes.
If we have nested checkpoints, this will remove the last checkpoint from the stack without modifying the state.
Definition at line 371 of file Tracker.cpp.
References assert(), Disabled, and Record.
Referenced by llvm::sandboxir::TransactionAcceptOrRevert::runOnRegion(), and llvm::sandboxir::TransactionAlwaysAccept::runOnRegion().
| void Tracker::dump | ( | ) | const |
Definition at line 399 of file Tracker.cpp.
References llvm::dbgs(), and dump().
Referenced by dump().
| void Tracker::dump | ( | raw_ostream & | OS | ) | const |
Definition at line 389 of file Tracker.cpp.
References llvm::enumerate(), and llvm::find().
|
inline |
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled.
\Returns true if tracking is enabled.
Definition at line 505 of file Tracker.h.
References isTracking(), and track().
Referenced by llvm::sandboxir::PHINode::addIncoming(), llvm::sandboxir::Context::registerValue(), llvm::sandboxir::PHINode::removeIncomingValue(), and llvm::sandboxir::PHINode::removeIncomingValue().
|
inline |
\Returns true if there are no changes tracked.
Definition at line 485 of file Tracker.h.
Referenced by llvm::sandboxir::TransactionAcceptOrRevert::runOnRegion(), llvm::sandboxir::TransactionAlwaysAccept::runOnRegion(), and llvm::sandboxir::TransactionAlwaysRevert::runOnRegion().
|
inline |
Definition at line 483 of file Tracker.h.
Referenced by llvm::sandboxir::TransactionAlwaysAccept::runOnRegion(), and llvm::sandboxir::TransactionAlwaysRevert::runOnRegion().
|
inline |
|
inline |
\Returns true if the tracker is recording changes.
Definition at line 512 of file Tracker.h.
References Record.
Referenced by emplaceIfTracking(), llvm::sandboxir::Instruction::eraseFromParent(), llvm::sandboxir::Value::replaceAllUsesWith(), and track().
|
inline |
| void Tracker::revert | ( | bool | RevertAll = false | ) |
Stops tracking and reverts to saved state.
If we have nested checkpoints this will revert the state to the last checkpoint.
Definition at line 341 of file Tracker.cpp.
References assert(), Disabled, Record, llvm::reverse(), and Reverting.
Referenced by llvm::sandboxir::TransactionAcceptOrRevert::runOnRegion(), and llvm::sandboxir::TransactionAlwaysRevert::runOnRegion().
| void Tracker::save | ( | ) |
Turns on IR tracking.
If tracking is already enabled this creates a new nested checkpoint.
Definition at line 331 of file Tracker.cpp.
References Record.
|
inline |
Record Change and take ownership.
This is the main function used to track Sandbox IR changes.
Definition at line 488 of file Tracker.h.
References assert(), InMiddleOfCreatingChange, isTracking(), and Record.
Referenced by emplaceIfTracking(), llvm::sandboxir::Instruction::eraseFromParent(), and llvm::sandboxir::Value::replaceAllUsesWith().
|
friend |
| bool llvm::sandboxir::Tracker::InMiddleOfCreatingChange = false |