21 if (
PassID ==
"Debug Variable Analysis")
24 return runOnMachineFunction(MF,
true);
29 if (
PassID ==
"Debug Variable Analysis")
31 runOnMachineFunction(MF,
false);
36void DroppedVariableStatsMIR::runOnMachineFunction(
const MachineFunction *MF,
40 run(DebugVariables, Before);
43void DroppedVariableStatsMIR::calculateDroppedVarStatsOnMachineFunction(
49 "MachineFunction", Func);
52void DroppedVariableStatsMIR::visitEveryInstruction(
unsigned &DroppedCount,
54 unsigned PrevDroppedCount = DroppedCount;
55 for (
const auto &
MBB : *MFunc) {
56 for (
const auto &
MI :
MBB) {
57 if (!
MI.isDebugInstr()) {
58 auto *DbgLoc =
MI.getDebugLoc().get();
66 if (PrevDroppedCount != DroppedCount) {
67 PrevDroppedCount = DroppedCount;
73void DroppedVariableStatsMIR::visitEveryDebugRecord(
DenseSet<VarID> &VarIDSet) {
74 for (
const auto &
MBB : *MFunc) {
75 for (
const auto &
MI :
MBB) {
76 if (
MI.isDebugValueLike()) {
77 auto *DbgVar =
MI.getDebugVariable();
80 auto DbgLoc =
MI.getDebugLoc();
===- DroppedVariableStatsMIR.h - Opt Diagnostics -*- C++ -*----------—===//
Implements a dense probed hash-table based set.
void runBeforePass(StringRef PassID, MachineFunction *MF)
void runAfterPass(StringRef PassID, MachineFunction *MF)
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.
LLVM_ABI void run(DebugVariables &DbgVariables, bool Before)
Run code to populate relevant data structures over an llvm::Function or llvm::MachineFunction.
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.
const BasicBlock & back() const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
This is an optimization pass for GlobalISel generic memory operations.
DebugVariableAggregate VarID
A unique key that represents one instance of a debug variable.