23 if (DroppedVarStatsEnabled)
24 llvm::outs() <<
"Pass Level, Pass Name, Num of Dropped Variables, Func or "
34 "DebugVariablesStack shouldn't be empty!");
41 unsigned DroppedCount = 0;
46 for (
VarID Var : DebugVariablesBeforeSet) {
47 if (DebugVariablesAfterSet.
contains(Var))
50 removeVarFromAllSets(Var, Func);
52 if (DroppedCount > 0) {
54 << FuncOrModName <<
"\n";
55 PassDroppedVariables =
true;
57 PassDroppedVariables =
false;
62 unsigned &DroppedCount) {
63 if (!isVarInScopeAt(DbgLoc, Var))
85void DroppedVariableStats::removeVarFromAllSets(
VarID Var,
const Function *
F) {
89 DebugVariablesMap[
F].DebugVariablesBefore.erase(Var);
92bool DroppedVariableStats::isScopeChildOfOrEqualTo(
const DIScope *Scope,
94 while (Scope !=
nullptr) {
95 if (Scope == VarScope)
97 Scope = Scope->getScope();
106 for (
const DILocation *Frame = Loc; Frame; Frame = Frame->getInlinedAt())
108 return isScopeChildOfOrEqualTo(Frame->getScope(),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
===- DroppedVariableStats.h - Opt Diagnostics -*- C++ -*-------------—===//
DILocalScope * getScope() const
Get the local scope for this variable.
Base class for scope-like contexts.
LLVM_ABI DILocation * getInlinedAt() const
Identifies a unique instance of a whole variable (discards/ignores fragment information).
Identifies a unique instance of a variable.
const DILocation * getInlinedAt() const
const DILocalVariable * getVariable() const
Implements a dense probed hash-table based set.
LLVM_ABI void populateVarIDSet(const DILocalVariable *DbgVar, DebugLoc DbgLoc, DenseSet< VarID > &VarIDSet)
Add the VarID of the debug record of DbgVar at DbgLoc to VarIDSet.
virtual void visitEveryInstruction(unsigned &DroppedCount, VarID Var)=0
Visit every llvm::Instruction or llvm::MachineInstruction and check if the debug variable denoted by ...
virtual void visitEveryDebugRecord(DenseSet< VarID > &VarIDSet)=0
Visit every debug record in an llvm::Function or llvm::MachineFunction and call populateVarIDSet on i...
bool DroppedVariableStatsEnabled
LLVM_ABI void run(DebugVariables &DbgVariables, bool Before)
Run code to populate relevant data structures over an llvm::Function or llvm::MachineFunction.
LLVM_ABI DroppedVariableStats(bool DroppedVarStatsEnabled)
LLVM_ABI void calculateDroppedStatsAndPrint(DebugVariables &DbgVariables, 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...
SmallVector< DenseMap< const Function *, DebugVariables > > DebugVariablesStack
A stack of a DenseMap, that maps DebugVariables for every pass to an llvm::Function.
LLVM_ABI bool updateDroppedCount(const DILocation *DbgLoc, VarID Var, unsigned &DroppedCount)
Check if a Var has been dropped or is a false positive.
Represent a constant reference to a string, i.e.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
This is an optimization pass for GlobalISel generic memory operations.
DebugVariableAggregate VarID
A unique key that represents one instance of a debug variable.
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
DenseSet< VarID > DebugVariablesAfter
DenseSet of VarIDs after an optimization pass has run.
DenseSet< VarID > DebugVariablesBefore
DenseSet of VarIDs before an optimization pass has run.