LLVM 20.0.0git
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::DroppedVariableStats Class Referenceabstract

A base class to collect and print dropped debug information variable statistics. More...

#include "llvm/Passes/DroppedVariableStats.h"

Inheritance diagram for llvm::DroppedVariableStats:
Inheritance graph
[legend]

Classes

struct  DebugVariables
 

Public Member Functions

 DroppedVariableStats (bool DroppedVarStatsEnabled)
 
virtual ~DroppedVariableStats ()
 
 DroppedVariableStats (const DroppedVariableStats &)=delete
 
void operator= (const DroppedVariableStats &)=delete
 
bool getPassDroppedVariables ()
 

Protected Member Functions

void setup ()
 
void cleanup ()
 
void calculateDroppedStatsAndPrint (DebugVariables &DbgVariables, StringRef FuncName, StringRef PassID, StringRef FuncOrModName, StringRef PassLevel, const Function *Func)
 Calculate the number of dropped variables in an llvm::Function or llvm::MachineFunction and print the relevant information to stdout.
 
bool updateDroppedCount (DILocation *DbgLoc, const DIScope *Scope, const DIScope *DbgValScope, DenseMap< VarID, DILocation * > &InlinedAtsMap, VarID Var, unsigned &DroppedCount)
 Check if a Var has been dropped or is a false positive.
 
void run (DebugVariables &DbgVariables, StringRef FuncName, bool Before)
 Run code to populate relevant data structures over an llvm::Function or llvm::MachineFunction.
 
void populateVarIDSetAndInlinedMap (const DILocalVariable *DbgVar, DebugLoc DbgLoc, DenseSet< VarID > &VarIDSet, DenseMap< StringRef, DenseMap< VarID, DILocation * > > &InlinedAtsMap, StringRef FuncName, bool Before)
 Populate the VarIDSet and InlinedAtMap with the relevant information needed for before and after pass analysis to determine dropped variable status.
 
virtual void visitEveryInstruction (unsigned &DroppedCount, DenseMap< VarID, DILocation * > &InlinedAtsMap, VarID Var)=0
 Visit every llvm::Instruction or llvm::MachineInstruction and check if the debug variable denoted by its ID Var may have been dropped by an optimization pass.
 
virtual void visitEveryDebugRecord (DenseSet< VarID > &VarIDSet, DenseMap< StringRef, DenseMap< VarID, DILocation * > > &InlinedAtsMap, StringRef FuncName, bool Before)=0
 Visit every debug record in an llvm::Function or llvm::MachineFunction and call populateVarIDSetAndInlinedMap on it.
 

Protected Attributes

bool DroppedVariableStatsEnabled = false
 
SmallVector< DenseMap< const Function *, DebugVariables > > DebugVariablesStack
 A stack of a DenseMap, that maps DebugVariables for every pass to an llvm::Function.
 
DenseSet< const DIScope * > VisitedScope
 A DenseSet tracking whether a scope was visited before.
 
SmallVector< DenseMap< StringRef, DenseMap< VarID, DILocation * > > > InlinedAts
 A stack of DenseMaps, which map the name of an llvm::Function to a DenseMap of VarIDs and their inlinedAt locations before an optimization pass has run.
 

Detailed Description

A base class to collect and print dropped debug information variable statistics.

Definition at line 36 of file DroppedVariableStats.h.

Constructor & Destructor Documentation

◆ DroppedVariableStats() [1/2]

llvm::DroppedVariableStats::DroppedVariableStats ( bool  DroppedVarStatsEnabled)
inline

Definition at line 38 of file DroppedVariableStats.h.

References llvm::outs().

◆ ~DroppedVariableStats()

virtual llvm::DroppedVariableStats::~DroppedVariableStats ( )
inlinevirtual

Definition at line 46 of file DroppedVariableStats.h.

◆ DroppedVariableStats() [2/2]

llvm::DroppedVariableStats::DroppedVariableStats ( const DroppedVariableStats )
delete

Member Function Documentation

◆ calculateDroppedStatsAndPrint()

void DroppedVariableStats::calculateDroppedStatsAndPrint ( DebugVariables DbgVariables,
StringRef  FuncName,
StringRef  PassID,
StringRef  FuncOrModName,
StringRef  PassLevel,
const Function Func 
)
protected

◆ cleanup()

void llvm::DroppedVariableStats::cleanup ( )
inlineprotected

◆ getPassDroppedVariables()

bool llvm::DroppedVariableStats::getPassDroppedVariables ( )
inline

Definition at line 52 of file DroppedVariableStats.h.

◆ operator=()

void llvm::DroppedVariableStats::operator= ( const DroppedVariableStats )
delete

◆ populateVarIDSetAndInlinedMap()

void DroppedVariableStats::populateVarIDSetAndInlinedMap ( const DILocalVariable DbgVar,
DebugLoc  DbgLoc,
DenseSet< VarID > &  VarIDSet,
DenseMap< StringRef, DenseMap< VarID, DILocation * > > &  InlinedAtsMap,
StringRef  FuncName,
bool  Before 
)
protected

Populate the VarIDSet and InlinedAtMap with the relevant information needed for before and after pass analysis to determine dropped variable status.

Definition at line 111 of file DroppedVariableStats.cpp.

References Before, llvm::DebugLoc::getInlinedAt(), llvm::DILocalVariable::getScope(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().

◆ run()

void DroppedVariableStats::run ( DebugVariables DbgVariables,
StringRef  FuncName,
bool  Before 
)
protected

◆ setup()

void llvm::DroppedVariableStats::setup ( )
inlineprotected

Definition at line 55 of file DroppedVariableStats.h.

References DebugVariablesStack, and InlinedAts.

Referenced by llvm::DroppedVariableStatsIR::runBeforePass().

◆ updateDroppedCount()

bool DroppedVariableStats::updateDroppedCount ( DILocation DbgLoc,
const DIScope Scope,
const DIScope DbgValScope,
DenseMap< VarID, DILocation * > &  InlinedAtsMap,
VarID  Var,
unsigned DroppedCount 
)
protected

Check if a Var has been dropped or is a false positive.

Also update the DroppedCount if a debug variable is dropped.

Definition at line 80 of file DroppedVariableStats.cpp.

◆ visitEveryDebugRecord()

virtual void llvm::DroppedVariableStats::visitEveryDebugRecord ( DenseSet< VarID > &  VarIDSet,
DenseMap< StringRef, DenseMap< VarID, DILocation * > > &  InlinedAtsMap,
StringRef  FuncName,
bool  Before 
)
protectedpure virtual

Visit every debug record in an llvm::Function or llvm::MachineFunction and call populateVarIDSetAndInlinedMap on it.

References DebugVariablesStack, llvm::drop_end(), and F.

Referenced by run().

◆ visitEveryInstruction()

virtual void llvm::DroppedVariableStats::visitEveryInstruction ( unsigned DroppedCount,
DenseMap< VarID, DILocation * > &  InlinedAtsMap,
VarID  Var 
)
protectedpure virtual

Visit every llvm::Instruction or llvm::MachineInstruction and check if the debug variable denoted by its ID Var may have been dropped by an optimization pass.

Referenced by calculateDroppedStatsAndPrint().

Member Data Documentation

◆ DebugVariablesStack

SmallVector<DenseMap<const Function *, DebugVariables> > llvm::DroppedVariableStats::DebugVariablesStack
protected

A stack of a DenseMap, that maps DebugVariables for every pass to an llvm::Function.

A stack is used because an optimization pass can call other passes.

Definition at line 82 of file DroppedVariableStats.h.

Referenced by cleanup(), setup(), and visitEveryDebugRecord().

◆ DroppedVariableStatsEnabled

bool llvm::DroppedVariableStats::DroppedVariableStatsEnabled = false
protected

◆ InlinedAts

SmallVector<DenseMap<StringRef, DenseMap<VarID, DILocation *> > > llvm::DroppedVariableStats::InlinedAts
protected

A stack of DenseMaps, which map the name of an llvm::Function to a DenseMap of VarIDs and their inlinedAt locations before an optimization pass has run.

Definition at line 89 of file DroppedVariableStats.h.

Referenced by calculateDroppedStatsAndPrint(), cleanup(), run(), and setup().

◆ VisitedScope

DenseSet<const DIScope *> llvm::DroppedVariableStats::VisitedScope
protected

A DenseSet tracking whether a scope was visited before.

Definition at line 85 of file DroppedVariableStats.h.


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