LLVM 22.0.0git
StackColoring.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "stack-coloring"

Functions

 STATISTIC (NumMarkerSeen, "Number of lifetime markers found.")
 STATISTIC (StackSpaceSaved, "Number of bytes saved due to merging slots.")
 STATISTIC (StackSlotMerged, "Number of stack slot merged.")
 STATISTIC (EscapedAllocas, "Number of allocas that escaped the lifetime region")
 INITIALIZE_PASS_BEGIN (StackColoringLegacy, DEBUG_TYPE, "Merge disjoint stack slots", false, false) INITIALIZE_PASS_END(StackColoringLegacy
static int getStartOrEndSlot (const MachineInstr &MI)

Variables

static cl::opt< boolDisableColoring ("no-stack-coloring", cl::init(false), cl::Hidden, cl::desc("Disable stack coloring"))
static cl::opt< boolProtectFromEscapedAllocas ("protect-from-escaped-allocas", cl::init(false), cl::Hidden, cl::desc("Do not optimize lifetime zones that " "are broken"))
 The user may write code that uses allocas outside of the declared lifetime zone.
static cl::opt< boolLifetimeStartOnFirstUse ("stackcoloring-lifetime-start-on-first-use", cl::init(true), cl::Hidden, cl::desc("Treat stack lifetimes as starting on first use, not on START marker."))
 Enable enhanced dataflow scheme for lifetime analysis (treat first use of stack slot as start of slot lifetime, as opposed to looking for LIFETIME_START marker).
 DEBUG_TYPE
Merge disjoint stack slots
Merge disjoint stack false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "stack-coloring"

Definition at line 66 of file StackColoring.cpp.

Function Documentation

◆ getStartOrEndSlot()

int getStartOrEndSlot ( const MachineInstr & MI)
inlinestatic

Definition at line 570 of file StackColoring.cpp.

References assert(), llvm::MachineOperand::getIndex(), and MI.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( StackColoringLegacy ,
DEBUG_TYPE ,
"Merge disjoint stack slots" ,
false ,
false  )

◆ STATISTIC() [1/4]

STATISTIC ( EscapedAllocas ,
"Number of allocas that escaped the lifetime region"  )

◆ STATISTIC() [2/4]

STATISTIC ( NumMarkerSeen ,
"Number of lifetime markers found."  )

◆ STATISTIC() [3/4]

STATISTIC ( StackSlotMerged ,
"Number of stack slot merged."  )

◆ STATISTIC() [4/4]

STATISTIC ( StackSpaceSaved ,
"Number of bytes saved due to merging slots."  )

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 526 of file StackColoring.cpp.

◆ DisableColoring

cl::opt< bool > DisableColoring("no-stack-coloring", cl::init(false), cl::Hidden, cl::desc("Disable stack coloring")) ( "no-stack-coloring" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("Disable stack coloring")  )
static

◆ false

Merge disjoint stack false

Definition at line 527 of file StackColoring.cpp.

◆ LifetimeStartOnFirstUse

cl::opt< bool > LifetimeStartOnFirstUse("stackcoloring-lifetime-start-on-first-use", cl::init(true), cl::Hidden, cl::desc("Treat stack lifetimes as starting on first use, not on START marker.")) ( "stackcoloring-lifetime-start-on-first-use" ,
cl::init(true) ,
cl::Hidden ,
cl::desc("Treat stack lifetimes as starting on first use, not on START marker.")  )
static

Enable enhanced dataflow scheme for lifetime analysis (treat first use of stack slot as start of slot lifetime, as opposed to looking for LIFETIME_START marker).

See "Implementation notes" below for more info.

◆ ProtectFromEscapedAllocas

cl::opt< bool > ProtectFromEscapedAllocas("protect-from-escaped-allocas", cl::init(false), cl::Hidden, cl::desc("Do not optimize lifetime zones that " "are broken")) ( "protect-from-escaped-allocas" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("Do not optimize lifetime zones that " "are broken")  )
static

The user may write code that uses allocas outside of the declared lifetime zone.

This can happen when the user returns a reference to a local data-structure. We can detect these cases and decide not to optimize the code. If this flag is enabled, we try to save the user. This option is treated as overriding LifetimeStartOnFirstUse below.

◆ slots

Merge disjoint stack slots

Definition at line 527 of file StackColoring.cpp.