LLVM  10.0.0
Debugify.h
Go to the documentation of this file.
1 //===- Debugify.h - Attach synthetic debug info to everything -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file Interface to the `debugify` synthetic debug info testing utility.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TRANSFORM_UTILS_DEBUGIFY_H
14 #define LLVM_TRANSFORM_UTILS_DEBUGIFY_H
15 
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/IR/PassManager.h"
19 
22 
23 struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
25 };
26 
27 /// Track how much `debugify` information has been lost.
29  /// Number of missing dbg.values.
30  unsigned NumDbgValuesMissing = 0;
31 
32  /// Number of dbg.values expected.
33  unsigned NumDbgValuesExpected = 0;
34 
35  /// Number of instructions with empty debug locations.
36  unsigned NumDbgLocsMissing = 0;
37 
38  /// Number of instructions expected to have debug locations.
39  unsigned NumDbgLocsExpected = 0;
40 
41  /// Get the ratio of missing/expected dbg.values.
42  float getMissingValueRatio() const {
43  return float(NumDbgValuesMissing) / float(NumDbgLocsExpected);
44  }
45 
46  /// Get the ratio of missing/expected instructions with locations.
47  float getEmptyLocationRatio() const {
48  return float(NumDbgLocsMissing) / float(NumDbgLocsExpected);
49  }
50 };
51 
52 /// Map pass names to a per-pass DebugifyStatistics instance.
54 
56 createCheckDebugifyModulePass(bool Strip = false,
57  llvm::StringRef NameOfWrappedPass = "",
58  DebugifyStatsMap *StatsMap = nullptr);
59 
61 createCheckDebugifyFunctionPass(bool Strip = false,
62  llvm::StringRef NameOfWrappedPass = "",
63  DebugifyStatsMap *StatsMap = nullptr);
64 
66  : public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
68 };
69 
70 #endif // LLVM_TRANSFORM_UTILS_DEBUGIFY_H
Track how much debugify information has been lost.
Definition: Debugify.h:28
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
llvm::FunctionPass * createCheckDebugifyFunctionPass(bool Strip=false, llvm::StringRef NameOfWrappedPass="", DebugifyStatsMap *StatsMap=nullptr)
Definition: Debugify.cpp:408
llvm::ModulePass * createDebugifyModulePass()
Definition: Debugify.cpp:391
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM)
Definition: Debugify.cpp:397
llvm::ModulePass * createCheckDebugifyModulePass(bool Strip=false, llvm::StringRef NameOfWrappedPass="", DebugifyStatsMap *StatsMap=nullptr)
Definition: Debugify.cpp:402
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:373
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:282
llvm::FunctionPass * createDebugifyFunctionPass()
Definition: Debugify.cpp:393
float getEmptyLocationRatio() const
Get the ratio of missing/expected instructions with locations.
Definition: Debugify.h:47
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:222
float getMissingValueRatio() const
Get the ratio of missing/expected dbg.values.
Definition: Debugify.h:42
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.