class AllocaSlices

Declaration

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

Description

Representation of the alloca slices. This class represents the slices of an alloca which are formed by its various uses. If a pointer escapes, we can't fully build a representation for the slices used and we reflect that in this structure. The uses are stored, sorted by increasing beginning offset and with unsplittable slices starting at a particular offset before splittable slices.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:218

Member Variables

private llvm::AllocaInst& AI
Handle to alloca instruction to simplify method interfaces.
private llvm::Instruction* PointerEscapingInstr
When an instruction (potentially) escapes the pointer to the alloca, we store a pointer to that here and abort trying to form slices of the alloca. This will be null if the alloca slices are analyzed successfully.
private anonymous struct / union Slices
We store a vector of the slices formed by uses of the alloca here. This vector is sorted by increasing begin offset, and then the unsplittable slices before the splittable ones. See the Slice inner class for more details.
private SmallVector<llvm::Instruction*, 8> DeadUsers
Note that these are not separated by slice. This is because we expect an alloca to be completely rewritten or not rewritten at all. If rewritten, all these instructions can simply be removed and replaced with poison as they come from outside of the allocated space.
private SmallVector<llvm::Use*, 8> DeadUseIfPromotable
Uses which will become dead if can promote the alloca.
private SmallVector<llvm::Use*, 8> DeadOperands
These are operands that in their particular use can be replaced with poison when we rewrite the alloca. These show up in out-of-bounds inputs to PHI nodes and the like. They aren't entirely dead (there might be a GEP back into the bounds using it elsewhere) and nor is the PHI, but we want to swap this particular input for poison to simplify the use lists of the alloca.

Method Overview

  • public AllocaSlices(const llvm::DataLayout & DL, llvm::AllocaInst & AI)
  • public llvm::sroa::AllocaSlices::iterator begin()
  • public llvm::sroa::AllocaSlices::const_iterator begin() const
  • public void dump() const
  • public void dump(llvm::sroa::AllocaSlices::const_iterator I) const
  • public llvm::sroa::AllocaSlices::iterator end()
  • public llvm::sroa::AllocaSlices::const_iterator end() const
  • public void erase(llvm::sroa::AllocaSlices::iterator Start, llvm::sroa::AllocaSlices::iterator Stop)
  • public ArrayRef<llvm::Use *> getDeadOperands() const
  • public ArrayRef<llvm::Instruction *> getDeadUsers() const
  • public ArrayRef<llvm::Use *> getDeadUsesIfPromotable() const
  • public void insert(ArrayRef<(anonymous namespace)::Slice> NewSlices)
  • public bool isEscaped() const
  • public iterator_range<llvm::sroa::AllocaSlices::partition_iterator> partitions()
  • public void print(llvm::raw_ostream & OS, llvm::sroa::AllocaSlices::const_iterator I, llvm::StringRef Indent = " ") const
  • public void print(llvm::raw_ostream & OS) const
  • public void printSlice(llvm::raw_ostream & OS, llvm::sroa::AllocaSlices::const_iterator I, llvm::StringRef Indent = " ") const
  • public void printUse(llvm::raw_ostream & OS, llvm::sroa::AllocaSlices::const_iterator I, llvm::StringRef Indent = " ") const

Methods

AllocaSlices(const llvm::DataLayout& DL,
             llvm::AllocaInst& AI)

Description

Construct the slices of a particular alloca.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:221

Parameters

const llvm::DataLayout& DL
llvm::AllocaInst& AI

llvm::sroa::AllocaSlices::iterator begin()

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:234

llvm::sroa::AllocaSlices::const_iterator begin()
    const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:240

void dump() const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:289

void dump(llvm::sroa::AllocaSlices::const_iterator
              I) const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:288

Parameters

llvm::sroa::AllocaSlices::const_iterator I

llvm::sroa::AllocaSlices::iterator end()

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:235

llvm::sroa::AllocaSlices::const_iterator end()
    const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:241

void erase(
    llvm::sroa::AllocaSlices::iterator Start,
    llvm::sroa::AllocaSlices::iterator Stop)

Description

Erase a range of slices.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:245

Parameters

llvm::sroa::AllocaSlices::iterator Start
llvm::sroa::AllocaSlices::iterator Stop

ArrayRef<llvm::Use*> getDeadOperands() const

Description

Access the dead operands referring to this alloca. These are operands which have cannot actually be used to refer to the alloca as they are outside its range and the user doesn't correct for that. These mostly consist of PHI node inputs and the like which we just need to replace with undef.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:279

ArrayRef<llvm::Instruction*> getDeadUsers() const

Description

Access the dead users for this alloca.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:266

ArrayRef<llvm::Use*> getDeadUsesIfPromotable()
    const

Description

Access Uses that should be dropped if the alloca is promotable.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:269

void insert(ArrayRef<(anonymous namespace)::Slice>
                NewSlices)

Description

Insert new slices for this alloca. This moves the slices into the alloca's slices collection, and re-sorts everything so that the usual ordering properties of the alloca's slices hold.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:252

Parameters

ArrayRef<(anonymous namespace)::Slice> NewSlices

bool isEscaped() const

Description

Test whether a pointer to the allocation escapes our analysis. If this is true, the slices are never fully built and should be ignored.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:227

iterator_range<
    llvm::sroa::AllocaSlices::partition_iterator>
partitions()

Description

A forward range over the partitions of the alloca's slices. This accesses an iterator range over the partitions of the alloca's slices. It computes these partitions on the fly based on the overlapping offsets of the slices and the ability to split them. It will visit "empty" partitions to cover regions of the alloca only accessed via split slices.

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:263

void print(
    llvm::raw_ostream& OS,
    llvm::sroa::AllocaSlices::const_iterator I,
    llvm::StringRef Indent = "  ") const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:282

Parameters

llvm::raw_ostream& OS
llvm::sroa::AllocaSlices::const_iterator I
llvm::StringRef Indent = " "

void print(llvm::raw_ostream& OS) const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:287

Parameters

llvm::raw_ostream& OS

void printSlice(
    llvm::raw_ostream& OS,
    llvm::sroa::AllocaSlices::const_iterator I,
    llvm::StringRef Indent = "  ") const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:283

Parameters

llvm::raw_ostream& OS
llvm::sroa::AllocaSlices::const_iterator I
llvm::StringRef Indent = " "

void printUse(
    llvm::raw_ostream& OS,
    llvm::sroa::AllocaSlices::const_iterator I,
    llvm::StringRef Indent = "  ") const

Declared at: llvm/lib/Transforms/Scalar/SROA.cpp:285

Parameters

llvm::raw_ostream& OS
llvm::sroa::AllocaSlices::const_iterator I
llvm::StringRef Indent = " "