21 if (PassID ==
"Debug Variable Analysis")
24 return runOnMachineFunction(MF,
true);
29 if (PassID ==
"Debug Variable Analysis")
31 runOnMachineFunction(MF,
false);
32 calculateDroppedVarStatsOnMachineFunction(MF, PassID, MF->
getName().
str());
36void DroppedVariableStatsMIR::runOnMachineFunction(
const MachineFunction *MF,
41 run(DebugVariables, FuncName, Before);
44void DroppedVariableStatsMIR::calculateDroppedVarStatsOnMachineFunction(
51 "MachineFunction", Func);
54void DroppedVariableStatsMIR::visitEveryInstruction(
57 unsigned PrevDroppedCount = DroppedCount;
58 const DIScope *DbgValScope = std::get<0>(Var);
59 for (
const auto &
MBB : *MFunc) {
60 for (
const auto &
MI :
MBB) {
61 if (!
MI.isDebugInstr()) {
62 auto *DbgLoc =
MI.getDebugLoc().get();
66 auto *
Scope = DbgLoc->getScope();
72 if (PrevDroppedCount != DroppedCount) {
73 PrevDroppedCount = DroppedCount;
79void DroppedVariableStatsMIR::visitEveryDebugRecord(
83 for (
const auto &
MBB : *MFunc) {
84 for (
const auto &
MI :
MBB) {
85 if (
MI.isDebugValueLike()) {
86 auto *DbgVar =
MI.getDebugVariable();
89 auto DbgLoc =
MI.getDebugLoc();
===- DroppedVariableStatsMIR.h - Opt Diagnostics -*- C++ -*----------—===//
Base class for scope-like contexts.
Implements a dense probed hash-table based set.
void runBeforePass(StringRef PassID, MachineFunction *MF)
void runAfterPass(StringRef PassID, MachineFunction *MF)
LLVM_ABI 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...
LLVM_ABI 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.
LLVM_ABI 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...
SmallVector< DenseMap< const Function *, DebugVariables > > DebugVariablesStack
A stack of a DenseMap, that maps DebugVariables for every pass to an llvm::Function.
LLVM_ABI void run(DebugVariables &DbgVariables, StringRef FuncName, bool Before)
Run code to populate relevant data structures over an llvm::Function or llvm::MachineFunction.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Function & getFunction()
Return the LLVM function that this machine code represents.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
This is an optimization pass for GlobalISel generic memory operations.
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.