22template <
typename IRUnitT>
23const IRUnitT *DroppedVariableStatsIR::unwrapIR(
Any IR) {
24 const IRUnitT **IRPtr = llvm::any_cast<const IRUnitT *>(&
IR);
25 return IRPtr ? *IRPtr :
nullptr;
30 if (
const auto *M = unwrapIR<Module>(
IR))
31 return this->runOnModule(
P, M,
true);
32 if (
const auto *
F = unwrapIR<Function>(
IR))
33 return this->runOnFunction(
P,
F,
true);
37 if (
const auto *M = unwrapIR<Module>(
IR))
38 runAfterPassModule(
P, M);
39 else if (
const auto *
F = unwrapIR<Function>(
IR))
40 runAfterPassFunction(
P,
F);
44void DroppedVariableStatsIR::runAfterPassFunction(
StringRef PassID,
46 runOnFunction(PassID,
F,
false);
47 calculateDroppedVarStatsOnFunction(
F, PassID,
F->getName().str(),
"Function");
50void DroppedVariableStatsIR::runAfterPassModule(
StringRef PassID,
52 runOnModule(PassID, M,
false);
53 calculateDroppedVarStatsOnModule(M, PassID, M->getName().str(),
"Module");
59 auto FuncName =
F->getName();
61 run(DebugVariables, FuncName, Before);
64void DroppedVariableStatsIR::calculateDroppedVarStatsOnFunction(
74void DroppedVariableStatsIR::runOnModule(
StringRef PassID,
const Module *M,
77 runOnFunction(PassID, &
F, Before);
81void DroppedVariableStatsIR::calculateDroppedVarStatsOnModule(
85 calculateDroppedVarStatsOnFunction(&
F, PassID, FuncOrModName, PassLevel);
104void DroppedVariableStatsIR::visitEveryInstruction(
107 const DIScope *DbgValScope = std::get<0>(Var);
109 auto *DbgLoc =
I.getDebugLoc().get();
113 InlinedAtsMap, Var, DroppedCount))
118void DroppedVariableStatsIR::visitEveryDebugRecord(
124 if (
auto *Dbg = dyn_cast<DbgVariableRecord>(&DR)) {
125 auto *DbgVar =
Dbg->getVariable();
126 auto DbgLoc = DR.getDebugLoc();
Expand Atomic instructions
===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*-----------—===//
Module.h This file contains the declarations for the Module class.
Legalize the Machine IR a function s Machine IR
PassInstrumentationCallbacks PIC
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
Base class for scope-like contexts.
Base class for non-instruction debug metadata records that have positions within IR.
Implements a dense probed hash-table based set.
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void runAfterPass(StringRef P, Any IR)
void runBeforePass(StringRef P, Any IR)
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.
bool DroppedVariableStatsEnabled
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.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
StringRef - Represent a constant reference to a string, i.e.
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.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerAfterPassInvalidatedCallback(CallableT C, bool ToFront=false)
void registerBeforeNonSkippedPassCallback(CallableT C)
void registerAfterPassCallback(CallableT C, bool ToFront=false)