[UpdateCCTestChecks] Detect function mangled name on separate line
[llvm-core.git] / tools / opt / Debugify.h
blob266f577951aedd3291b875cb5511c28cfe45cc8c
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 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TOOLS_OPT_DEBUGIFY_H
14 #define LLVM_TOOLS_OPT_DEBUGIFY_H
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/IR/PassManager.h"
19 #include "llvm/Support/raw_ostream.h"
21 llvm::ModulePass *createDebugifyModulePass();
22 llvm::FunctionPass *createDebugifyFunctionPass();
24 struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
25 llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
28 /// Track how much `debugify` information has been lost.
29 struct DebugifyStatistics {
30 /// Number of missing dbg.values.
31 unsigned NumDbgValuesMissing = 0;
33 /// Number of dbg.values expected.
34 unsigned NumDbgValuesExpected = 0;
36 /// Number of instructions with empty debug locations.
37 unsigned NumDbgLocsMissing = 0;
39 /// Number of instructions expected to have debug locations.
40 unsigned NumDbgLocsExpected = 0;
42 /// Get the ratio of missing/expected dbg.values.
43 float getMissingValueRatio() const {
44 return float(NumDbgValuesMissing) / float(NumDbgLocsExpected);
47 /// Get the ratio of missing/expected instructions with locations.
48 float getEmptyLocationRatio() const {
49 return float(NumDbgLocsMissing) / float(NumDbgLocsExpected);
53 /// Map pass names to a per-pass DebugifyStatistics instance.
54 using DebugifyStatsMap = llvm::MapVector<llvm::StringRef, DebugifyStatistics>;
56 /// Export per-pass debugify statistics to the file specified by \p Path.
57 void exportDebugifyStats(llvm::StringRef Path, const DebugifyStatsMap &Map);
59 llvm::ModulePass *
60 createCheckDebugifyModulePass(bool Strip = false,
61 llvm::StringRef NameOfWrappedPass = "",
62 DebugifyStatsMap *StatsMap = nullptr);
64 llvm::FunctionPass *
65 createCheckDebugifyFunctionPass(bool Strip = false,
66 llvm::StringRef NameOfWrappedPass = "",
67 DebugifyStatsMap *StatsMap = nullptr);
69 struct NewPMCheckDebugifyPass
70 : public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
71 llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
74 #endif // LLVM_TOOLS_OPT_DEBUGIFY_H