xref: /freebsd/contrib/llvm-project/llvm/include/llvm/CodeGen/DroppedVariableStatsMIR.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 ///===- DroppedVariableStatsMIR.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_VALUEs that get dropped due to an optimization pass.
11 ///
12 ///===---------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_DROPPEDVARIABLESTATSMIR_H
15 #define LLVM_CODEGEN_DROPPEDVARIABLESTATSMIR_H
16 
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/IR/DroppedVariableStats.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace llvm {
22 
23 /// A class to collect and print dropped debug information due to MIR
24 /// optimization passes. After every MIR pass is run, it will print how many
25 /// #DBG_VALUEs were dropped due to that pass.
26 class LLVM_ABI DroppedVariableStatsMIR : public DroppedVariableStats {
27 public:
DroppedVariableStatsMIR()28   DroppedVariableStatsMIR() : DroppedVariableStats(false) {}
29 
30   void runBeforePass(StringRef PassID, MachineFunction *MF);
31 
32   void runAfterPass(StringRef PassID, MachineFunction *MF);
33 
34 private:
35   const MachineFunction *MFunc;
36   /// Populate DebugVariablesBefore, DebugVariablesAfter, InlinedAts before or
37   /// after a pass has run to facilitate dropped variable calculation for an
38   /// llvm::MachineFunction.
39   void runOnMachineFunction(const MachineFunction *MF, bool Before);
40   /// Iterate over all Instructions in a MachineFunction and report any dropped
41   /// debug information.
42   void calculateDroppedVarStatsOnMachineFunction(const MachineFunction *MF,
43                                                  StringRef PassID,
44                                                  StringRef FuncOrModName);
45   /// Override base class method to run on an llvm::MachineFunction
46   /// specifically.
47   virtual void
48   visitEveryInstruction(unsigned &DroppedCount,
49                         DenseMap<VarID, DILocation *> &InlinedAtsMap,
50                         VarID Var) override;
51   /// Override base class method to run on DBG_VALUEs specifically.
52   virtual void visitEveryDebugRecord(
53       DenseSet<VarID> &VarIDSet,
54       DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
55       StringRef FuncName, bool Before) override;
56 };
57 
58 } // namespace llvm
59 
60 #endif
61