LLVM 22.0.0git
llvm::StackLifetime Class Reference

Compute live ranges of allocas. More...

#include "llvm/Analysis/StackLifetime.h"

Classes

class  LifetimeAnnotationWriter
class  LiveRange
 This class represents a set of interesting instructions where an alloca is live. More...

Public Types

enum class  LivenessType { May , Must }

Public Member Functions

 StackLifetime (const Function &F, ArrayRef< const AllocaInst * > Allocas, LivenessType Type)
void run ()
iterator_range< filter_iterator< ArrayRef< const IntrinsicInst * >::const_iterator, std::function< bool(const IntrinsicInst *)> > > getMarkers () const
const LiveRangegetLiveRange (const AllocaInst *AI) const
 Returns a set of "interesting" instructions where the given alloca is live.
bool isReachable (const Instruction *I) const
 Returns true if instruction is reachable from entry.
bool isAliveAfter (const AllocaInst *AI, const Instruction *I) const
 Returns true if the alloca is alive after the instruction.
LiveRange getFullLiveRange () const
 Returns a live range that represents an alloca that is live throughout the entire function.
void print (raw_ostream &O)

Detailed Description

Compute live ranges of allocas.

Live ranges are represented as sets of "interesting" instructions, which are defined as instructions that may start or end an alloca's lifetime. These are:

  • lifetime.start and lifetime.end intrinsics
  • first instruction of any basic block Interesting instructions are numbered in the depth-first walk of the CFG, and in the program order inside each basic block.

Definition at line 37 of file StackLifetime.h.

Member Enumeration Documentation

◆ LivenessType

Enumerator
May 
Must 

Definition at line 83 of file StackLifetime.h.

Constructor & Destructor Documentation

◆ StackLifetime()

StackLifetime::StackLifetime ( const Function & F,
ArrayRef< const AllocaInst * > Allocas,
LivenessType Type )

Member Function Documentation

◆ getFullLiveRange()

LiveRange llvm::StackLifetime::getFullLiveRange ( ) const
inline

Returns a live range that represents an alloca that is live throughout the entire function.

Definition at line 160 of file StackLifetime.h.

References LiveRange.

Referenced by run().

◆ getLiveRange()

const StackLifetime::LiveRange & StackLifetime::getLiveRange ( const AllocaInst * AI) const

Returns a set of "interesting" instructions where the given alloca is live.

Not all instructions in a function are interesting: we pick a set that is large enough for LiveRange::Overlaps to be correct.

Definition at line 35 of file StackLifetime.cpp.

References assert(), and IT.

Referenced by isAliveAfter().

◆ getMarkers()

iterator_range< filter_iterator< ArrayRef< const IntrinsicInst * >::const_iterator, std::function< bool(const IntrinsicInst *)> > > llvm::StackLifetime::getMarkers ( ) const
inline

Definition at line 141 of file StackLifetime.h.

References I, and llvm::make_filter_range().

◆ isAliveAfter()

bool StackLifetime::isAliveAfter ( const AllocaInst * AI,
const Instruction * I ) const

Returns true if the alloca is alive after the instruction.

Definition at line 45 of file StackLifetime.cpp.

References assert(), getLiveRange(), I, and llvm::StackLifetime::LiveRange::test().

◆ isReachable()

bool StackLifetime::isReachable ( const Instruction * I) const

Returns true if instruction is reachable from entry.

Definition at line 41 of file StackLifetime.cpp.

References I.

◆ print()

void StackLifetime::print ( raw_ostream & O)

Definition at line 355 of file StackLifetime.cpp.

Referenced by llvm::StackLifetimePrinterPass::run().

◆ run()

void StackLifetime::run ( )

Definition at line 303 of file StackLifetime.cpp.

References getFullLiveRange(), I, LiveRange, and LLVM_DEBUG.

Referenced by llvm::StackLifetimePrinterPass::run().


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