LLVM 20.0.0git
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
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 }
 

Public Member Functions

 Tracker (Context &Ctx)
 
 ~Tracker ()
 
ContextgetContext () const
 
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.
 
void save ()
 Turns on IR tracking.
 
void accept ()
 Stops tracking and accept changes.
 
void revert ()
 Stops tracking and reverts to saved state.
 
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 440 of file Tracker.h.

Member Enumeration Documentation

◆ TrackerState

Enumerator
Disabled 
Record 

‍Tracking is disabled

Definition at line 442 of file Tracker.h.

Constructor & Destructor Documentation

◆ Tracker()

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

Definition at line 465 of file Tracker.h.

◆ ~Tracker()

Tracker::~Tracker ( )

Definition at line 141 of file Tracker.cpp.

References assert().

Member Function Documentation

◆ accept()

void Tracker::accept ( )

Stops tracking and accept changes.

Definition at line 359 of file Tracker.cpp.

References assert(), Disabled, and Record.

Referenced by llvm::sandboxir::Context::accept().

◆ dump() [1/2]

void Tracker::dump ( ) const

Definition at line 375 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 368 of file Tracker.cpp.

References llvm::enumerate(), Idx, and OS.

◆ 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 495 of file Tracker.h.

References isTracking(), and track().

Referenced by llvm::sandboxir::SwitchInst::addCase(), llvm::sandboxir::CatchSwitchInst::addHandler(), llvm::sandboxir::PHINode::addIncoming(), llvm::Instruction::cloneDebugInfoFrom(), llvm::sandboxir::ShuffleVectorInst::commute(), llvm::Instruction::dropOneDbgRecord(), llvm::Instruction::getAccessType(), llvm::Instruction::getModule(), llvm::sandboxir::Instruction::insertInto(), llvm::sandboxir::Context::registerValue(), llvm::sandboxir::SwitchInst::removeCase(), llvm::sandboxir::PHINode::removeIncomingValue(), llvm::Instruction::replaceSuccessorWith(), llvm::sandboxir::Use::set(), llvm::sandboxir::GlobalAlias::setAliasee(), llvm::sandboxir::AtomicRMWInst::setAlignment(), llvm::sandboxir::AtomicCmpXchgInst::setAlignment(), llvm::sandboxir::AllocaInst::setAlignment(), llvm::sandboxir::GlobalObject::setAlignment(), llvm::sandboxir::AllocaInst::setAllocatedType(), llvm::sandboxir::FuncletPadInst::setArgOperand(), llvm::sandboxir::CatchReturnInst::setCatchPad(), llvm::sandboxir::LandingPadInst::setCleanup(), llvm::sandboxir::CleanupReturnInst::setCleanupPad(), llvm::sandboxir::SwitchInst::setCondition(), llvm::sandboxir::GlobalVariable::setConstant(), llvm::sandboxir::CallBrInst::setDefaultDest(), llvm::sandboxir::SwitchInst::setDefaultDest(), llvm::sandboxir::GlobalVariable::setExternallyInitialized(), llvm::sandboxir::AtomicCmpXchgInst::setFailureOrdering(), llvm::sandboxir::Instruction::setFast(), llvm::sandboxir::Instruction::setFastMathFlags(), llvm::sandboxir::GlobalObject::setGlobalObjectSubClassData(), llvm::sandboxir::Instruction::setHasAllowReassoc(), llvm::sandboxir::Instruction::setHasAllowReciprocal(), llvm::sandboxir::Instruction::setHasApproxFunc(), llvm::sandboxir::Instruction::setHasNoInfs(), llvm::sandboxir::Instruction::setHasNoNaNs(), llvm::sandboxir::PHINode::setIncomingBlock(), llvm::sandboxir::PHINode::setIncomingValue(), llvm::sandboxir::GlobalVariable::setInitializer(), llvm::sandboxir::PossiblyDisjointInst::setIsDisjoint(), llvm::sandboxir::Instruction::setIsExact(), llvm::sandboxir::PossiblyNonNegInst::setNonNeg(), llvm::sandboxir::User::setOperand(), llvm::sandboxir::AtomicRMWInst::setOrdering(), llvm::sandboxir::FuncletPadInst::setParentPad(), llvm::sandboxir::CatchSwitchInst::setParentPad(), llvm::sandboxir::CmpInst::setPredicate(), llvm::sandboxir::GlobalIFunc::setResolver(), llvm::sandboxir::GlobalObject::setSection(), llvm::sandboxir::ShuffleVectorInst::setShuffleMask(), llvm::sandboxir::CatchReturnInst::setSuccessor(), llvm::sandboxir::SwitchInst::setSuccessor(), llvm::sandboxir::AtomicCmpXchgInst::setSuccessOrdering(), llvm::sandboxir::FenceInst::setSyncScopeID(), llvm::sandboxir::AtomicCmpXchgInst::setSyncScopeID(), llvm::sandboxir::GlobalValue::setUnnamedAddr(), llvm::sandboxir::CleanupReturnInst::setUnwindDest(), llvm::sandboxir::AllocaInst::setUsedWithInAlloca(), llvm::sandboxir::GlobalValue::setVisibility(), llvm::sandboxir::LoadInst::setVolatile(), llvm::sandboxir::StoreInst::setVolatile(), llvm::sandboxir::AtomicCmpXchgInst::setVolatile(), llvm::sandboxir::AtomicCmpXchgInst::setWeak(), llvm::sandboxir::Use::swap(), llvm::sandboxir::ICmpInst::swapOperands(), llvm::sandboxir::FCmpInst::swapOperands(), llvm::sandboxir::SelectInst::swapValues(), and llvm::Value::Value().

◆ getContext()

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

Definition at line 475 of file Tracker.h.

Referenced by llvm::sandboxir::EraseFromParent::revert().

◆ getState()

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

\Returns the current state of the tracker.

Definition at line 504 of file Tracker.h.

◆ isTracking()

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

\Returns true if the tracker is recording changes.

Definition at line 502 of file Tracker.h.

References Record.

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

◆ revert()

void Tracker::revert ( )

Stops tracking and reverts to saved state.

Definition at line 348 of file Tracker.cpp.

References assert(), Disabled, llvm::sandboxir::IRSnapshotChecker::expectNoDiff(), Record, and llvm::reverse().

Referenced by llvm::sandboxir::Context::revert().

◆ save()

void Tracker::save ( )

Turns on IR tracking.

Definition at line 341 of file Tracker.cpp.

References Record, and llvm::sandboxir::IRSnapshotChecker::save().

Referenced by llvm::sandboxir::Context::save().

◆ 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 478 of file Tracker.h.

References assert(), InMiddleOfCreatingChange, isTracking(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and Record.

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

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 515 of file Tracker.h.

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 462 of file Tracker.h.

Referenced by track().


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