1 //===- Debugify.h - Attach synthetic debug info to everything -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \file Interface to the `debugify` synthetic debug info testing utility.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_OPT_DEBUGIFY_H
15 #define LLVM_TOOLS_OPT_DEBUGIFY_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/IR/PassManager.h"
20 #include "llvm/Support/raw_ostream.h"
22 llvm::ModulePass
*createDebugifyModulePass();
23 llvm::FunctionPass
*createDebugifyFunctionPass();
25 struct NewPMDebugifyPass
: public llvm::PassInfoMixin
<NewPMDebugifyPass
> {
26 llvm::PreservedAnalyses
run(llvm::Module
&M
, llvm::ModuleAnalysisManager
&AM
);
29 /// Track how much `debugify` information has been lost.
30 struct DebugifyStatistics
{
31 /// Number of missing dbg.values.
32 unsigned NumDbgValuesMissing
= 0;
34 /// Number of dbg.values expected.
35 unsigned NumDbgValuesExpected
= 0;
37 /// Number of instructions with empty debug locations.
38 unsigned NumDbgLocsMissing
= 0;
40 /// Number of instructions expected to have debug locations.
41 unsigned NumDbgLocsExpected
= 0;
43 /// Get the ratio of missing/expected dbg.values.
44 float getMissingValueRatio() const {
45 return float(NumDbgValuesMissing
) / float(NumDbgLocsExpected
);
48 /// Get the ratio of missing/expected instructions with locations.
49 float getEmptyLocationRatio() const {
50 return float(NumDbgLocsMissing
) / float(NumDbgLocsExpected
);
54 /// Map pass names to a per-pass DebugifyStatistics instance.
55 using DebugifyStatsMap
= llvm::MapVector
<llvm::StringRef
, DebugifyStatistics
>;
57 /// Export per-pass debugify statistics to the file specified by \p Path.
58 void exportDebugifyStats(llvm::StringRef Path
, const DebugifyStatsMap
&Map
);
61 createCheckDebugifyModulePass(bool Strip
= false,
62 llvm::StringRef NameOfWrappedPass
= "",
63 DebugifyStatsMap
*StatsMap
= nullptr);
66 createCheckDebugifyFunctionPass(bool Strip
= false,
67 llvm::StringRef NameOfWrappedPass
= "",
68 DebugifyStatsMap
*StatsMap
= nullptr);
70 struct NewPMCheckDebugifyPass
71 : public llvm::PassInfoMixin
<NewPMCheckDebugifyPass
> {
72 llvm::PreservedAnalyses
run(llvm::Module
&M
, llvm::ModuleAnalysisManager
&AM
);
75 #endif // LLVM_TOOLS_OPT_DEBUGIFY_H