LLVM 22.0.0git
DroppedVariableStatsIR.h
Go to the documentation of this file.
1///===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*--------------===//
2///
3/// Part of the LLVM Project, under the Apache License v2.0 with LLVM
4/// Exceptions. See https://llvm.org/LICENSE.txt for license information.
5/// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6///
7///===---------------------------------------------------------------------===//
8/// \file
9/// Dropped Variable Statistics for Debug Information. Reports any number
10/// of #dbg_value that get dropped due to an optimization pass.
11///
12///===---------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_DROPPEDVARIABLESTATSIR_H
15#define LLVM_CODEGEN_DROPPEDVARIABLESTATSIR_H
16
19
20namespace llvm {
21
22class Any;
23class StringRef;
25class Function;
26class Module;
27class DILocation;
28
29/// A class to collect and print dropped debug information due to LLVM IR
30/// optimization passes. After every LLVM IR pass is run, it will print how many
31/// #dbg_values were dropped due to that pass.
33public:
34 DroppedVariableStatsIR(bool DroppedVarStatsEnabled)
35 : llvm::DroppedVariableStats(DroppedVarStatsEnabled) {}
36
37 void runBeforePass(StringRef P, Any IR);
38
39 void runAfterPass(StringRef P, Any IR);
40
42
43private:
44 const Function *Func;
45
46 void runAfterPassFunction(StringRef PassID, const Function *F);
47
48 void runAfterPassModule(StringRef PassID, const Module *M);
49
50 /// Populate DebugVariablesBefore, DebugVariablesAfter, InlinedAts before or
51 /// after a pass has run to facilitate dropped variable calculation for an
52 /// llvm::Function.
53 void runOnFunction(StringRef PassID, const Function *F, bool Before);
54
55 /// Iterate over all Instructions in a Function and report any dropped debug
56 /// information.
57 void calculateDroppedVarStatsOnFunction(const Function *F, StringRef PassID,
58 StringRef FuncOrModName,
59 StringRef PassLevel);
60
61 /// Populate DebugVariablesBefore, DebugVariablesAfter, InlinedAts before or
62 /// after a pass has run to facilitate dropped variable calculation for an
63 /// llvm::Module. Calls runOnFunction on every Function in the Module.
64 void runOnModule(StringRef PassID, const Module *M, bool Before);
65
66 /// Iterate over all Functions in a Module and report any dropped debug
67 /// information. Will call calculateDroppedVarStatsOnFunction on every
68 /// Function.
69 void calculateDroppedVarStatsOnModule(const Module *M, StringRef PassID,
70 StringRef FuncOrModName,
71 StringRef PassLevel);
72
73 /// Override base class method to run on an llvm::Function specifically.
74 virtual void
75 visitEveryInstruction(unsigned &DroppedCount,
76 DenseMap<VarID, DILocation *> &InlinedAtsMap,
77 VarID Var) override;
78
79 /// Override base class method to run on #dbg_values specifically.
80 virtual void visitEveryDebugRecord(
81 DenseSet<VarID> &VarIDSet,
83 StringRef FuncName, bool Before) override;
84
85 template <typename IRUnitT> static const IRUnitT *unwrapIR(Any IR);
86};
87
88} // namespace llvm
89
90#endif
#define LLVM_ABI
Definition Compiler.h:213
===- DroppedVariableStats.h - Opt Diagnostics -*- C++ -*-------------—===//
static bool runOnFunction(Function &F, bool PostInlining)
Legalize the Machine IR a function s Machine IR
Definition Legalizer.cpp:80
#define F(x, y, z)
Definition MD5.cpp:55
#define P(N)
SI registerCallbacks(PIC, &MAM)
PassInstrumentationCallbacks PIC
static const IRUnitT * unwrapIR(Any IR)
Implements a dense probed hash-table based set.
Definition DenseSet.h:261
DroppedVariableStatsIR(bool DroppedVarStatsEnabled)
LLVM_ABI DroppedVariableStats(bool DroppedVarStatsEnabled)
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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.