20 if (
PassID ==
"Debug Variable Analysis")
23 return runOnMachineFunction(MF,
true);
28 if (
PassID ==
"Debug Variable Analysis")
30 runOnMachineFunction(MF,
false);
35void DroppedVariableStatsMIR::runOnMachineFunction(
const MachineFunction *MF,
39 run(DebugVariables, Before);
42void DroppedVariableStatsMIR::calculateDroppedVarStatsOnMachineFunction(
48 "MachineFunction", Func);
51void DroppedVariableStatsMIR::visitEveryInstruction(
unsigned &DroppedCount,
53 unsigned PrevDroppedCount = DroppedCount;
54 for (
const auto &
MBB : *MFunc) {
55 for (
const auto &
MI :
MBB) {
56 if (!
MI.isDebugInstr()) {
57 auto *DbgLoc =
MI.getDebugLoc().get();
65 if (PrevDroppedCount != DroppedCount) {
66 PrevDroppedCount = DroppedCount;
72void DroppedVariableStatsMIR::visitEveryDebugRecord(
DenseSet<VarID> &VarIDSet) {
73 for (
const auto &
MBB : *MFunc) {
74 for (
const auto &
MI :
MBB) {
75 if (
MI.isDebugValueLike()) {
76 auto *DbgVar =
MI.getDebugVariable();
79 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.