LLVM 23.0.0git
llvm::sandboxir::Tracker Class Reference

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 ()
ContextgetContext () 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 ()
 Stops tracking and accept changes.
LLVM_ABI void revert ()
 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_ostreamoperator<< (raw_ostream &OS, const Tracker &Tracker)

Detailed Description

The tracker collects all the change objects and implements the main API for saving / reverting / accepting.

Definition at line 442 of file Tracker.h.

Member Enumeration Documentation

◆ TrackerState

Enumerator
Disabled 
Record 

Tracking is disabled

Reverting 

Tracking changes

Definition at line 444 of file Tracker.h.

Constructor & Destructor Documentation

◆ Tracker()

llvm::sandboxir::Tracker::Tracker ( Context & Ctx)
inlineexplicit

Definition at line 472 of file Tracker.h.

Referenced by operator<<.

◆ ~Tracker()

Tracker::~Tracker ( )

Definition at line 131 of file Tracker.cpp.

References assert().

Member Function Documentation

◆ accept()

void Tracker::accept ( )

Stops tracking and accept changes.

Definition at line 361 of file Tracker.cpp.

References assert(), Disabled, and Record.

Referenced by llvm::sandboxir::TransactionAcceptOrRevert::runOnRegion(), and llvm::sandboxir::TransactionAlwaysAccept::runOnRegion().

◆ dump() [1/2]

void Tracker::dump ( ) const

Definition at line 384 of file Tracker.cpp.

References llvm::dbgs(), and dump().

Referenced by dump().

◆ dump() [2/2]

void Tracker::dump ( raw_ostream & OS) const

Definition at line 374 of file Tracker.cpp.

References llvm::enumerate(), and llvm::find().

◆ emplaceIfTracking()

template<typename ChangeT, typename... ArgsT>
bool llvm::sandboxir::Tracker::emplaceIfTracking ( ArgsT... Args)
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 497 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().

◆ empty()

bool llvm::sandboxir::Tracker::empty ( ) const
inline

◆ getContext()

Context & llvm::sandboxir::Tracker::getContext ( ) const
inline

◆ getState()

TrackerState llvm::sandboxir::Tracker::getState ( ) const
inline

\Returns the current state of the tracker.

Definition at line 506 of file Tracker.h.

◆ isTracking()

bool llvm::sandboxir::Tracker::isTracking ( ) const
inline

\Returns true if the tracker is recording changes.

Definition at line 504 of file Tracker.h.

References Record.

Referenced by emplaceIfTracking(), llvm::sandboxir::Instruction::eraseFromParent(), llvm::sandboxir::Value::replaceAllUsesWith(), and track().

◆ nestingDepth()

unsigned llvm::sandboxir::Tracker::nestingDepth ( ) const
inline
Returns
the number of nested (outstanding) checkpoints.

Definition at line 514 of file Tracker.h.

◆ revert()

void Tracker::revert ( )

Stops tracking and reverts to saved state.

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().

◆ save()

void Tracker::save ( )

Turns on IR tracking.

Definition at line 331 of file Tracker.cpp.

References Record.

◆ track()

void llvm::sandboxir::Tracker::track ( std::unique_ptr< IRChangeBase > && Change)
inline

Record Change and take ownership.

This is the main function used to track Sandbox IR changes.

Definition at line 480 of file Tracker.h.

References assert(), InMiddleOfCreatingChange, isTracking(), and Record.

Referenced by emplaceIfTracking(), llvm::sandboxir::Instruction::eraseFromParent(), and llvm::sandboxir::Value::replaceAllUsesWith().

◆ operator<<

raw_ostream & operator<< ( raw_ostream & OS,
const Tracker & Tracker )
friend

Definition at line 519 of file Tracker.h.

References Tracker().

Member Data Documentation

◆ InMiddleOfCreatingChange

bool llvm::sandboxir::Tracker::InMiddleOfCreatingChange = false

Helps catch bugs where we are creating new change objects while in the middle of creating other change objects.

Definition at line 469 of file Tracker.h.

Referenced by track().


The documentation for this class was generated from the following files: