class StackLifetime

Declaration

class StackLifetime { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:37

Member Variables

private const llvm::Function& F
private llvm::StackLifetime::LivenessType Type
private llvm::StackLifetime::LivenessMap BlockLiveness
private SmallVector<const llvm::IntrinsicInst*, 64> Instructions
Interesting instructions. Instructions of the same block are adjustent preserve in-block order.
private DenseMap<const llvm::BasicBlock*, std::pair<unsigned int, unsigned int>> BlockInstRange
A range [Start, End) of instruction ids for each basic block. Instructions inside each BB have monotonic and consecutive ids.
private ArrayRef<const llvm::AllocaInst*> Allocas
private unsigned int NumAllocas
private DenseMap<const llvm::AllocaInst*, unsigned int> AllocaNumbering
private SmallVector<llvm::StackLifetime::LiveRange, 8> LiveRanges
LiveRange for allocas.
private llvm::BitVector InterestingAllocas
The set of allocas that have at least one lifetime.start. All other allocas get LiveRange that corresponds to the entire function.
private DenseMap< const llvm::BasicBlock*, SmallVector<std::pair<unsigned int, Marker>, 4>> BBMarkers
List of {InstNo, {AllocaNo, IsStart}} for each BB, ordered by InstNo.
private bool HasUnknownLifetimeStartOrEnd = false

Method Overview

Methods

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

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:135

Parameters

const llvm::Function& F
ArrayRef<const llvm::AllocaInst*> Allocas
llvm::StackLifetime::LivenessType Type

void calculateLiveIntervals()

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:132

void calculateLocalLiveness()

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:131

void collectMarkers()

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:130

void dumpAllocas() const

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:126

void dumpBlockLiveness() const

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:127

void dumpLiveRanges() const

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:128

llvm::StackLifetime::LiveRange getFullLiveRange()
    const

Description

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

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:162

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

Description

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.

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:152

Parameters

const llvm::AllocaInst* AI

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

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:143

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

Description

Returns true if the alloca is alive after the instruction.

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:158

Parameters

const llvm::AllocaInst* AI
const llvm::Instruction* I

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

Description

Returns true if instruction is reachable from entry.

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:155

Parameters

const llvm::Instruction* I

void print(llvm::raw_ostream& O)

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:166

Parameters

llvm::raw_ostream& O

void run()

Declared at: llvm/include/llvm/Analysis/StackLifetime.h:138