LLVM: include/llvm/Transforms/Utils/Debugify.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_TRANSFORMS_UTILS_DEBUGIFY_H
15#define LLVM_TRANSFORMS_UTILS_DEBUGIFY_H
16
27
34
35
37
39
41
42
44
46};
47
48namespace llvm {
49class DIBuilder;
50
51
52
53
54
55
56
57
58
62
63
64
65
67
68
69
70
71
72
73
74
79
80
81
82
83
84
85
86
91 StringRef OrigDIVerifyBugsReportFilePath);
92}
93
94
96
105
109 enum DebugifyMode Mode = DebugifyMode::NoDebugify;
110public:
112 enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
115 : NameOfWrappedPass(NameOfWrappedPass),
116 DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode) {}
117
119};
120
121
122
124
126
127
129
130
132
133
135
136
139 }
140
141
144 }
145};
146
147
149
151 bool Strip = false, llvm::StringRef NameOfWrappedPass = "",
156
158 bool Strip = false, llvm::StringRef NameOfWrappedPass = "",
163
171 bool Strip;
172public:
174 bool Strip = false, llvm::StringRef NameOfWrappedPass = "",
176 enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
179 : NameOfWrappedPass(NameOfWrappedPass),
180 OrigDIVerifyBugsReportFilePath(OrigDIVerifyBugsReportFilePath),
181 StatsMap(StatsMap), DebugInfoBeforePass(DebugInfoBeforePass), Mode(Mode),
182 Strip(Strip) {}
183
185};
186
187namespace llvm {
189
193 enum DebugifyMode Mode = DebugifyMode::NoDebugify;
195
196public:
199
202
204 DebugInfoBeforePass = &PerPassMap;
205 }
207
209 OrigDIVerifyBugsReportFilePath = BugsReportFilePath;
210 }
212 return OrigDIVerifyBugsReportFilePath;
213 }
214
216
218 return Mode == DebugifyMode::SyntheticDebugInfo;
219 }
221 return Mode == DebugifyMode::OriginalDebugInfo;
222 }
223};
224
225
226
227
228
230 StringRef OrigDIVerifyBugsReportFilePath;
233 enum DebugifyMode Mode = DebugifyMode::NoDebugify;
234
235public:
237
239
240
241 bool WrapWithDebugify = Mode != DebugifyMode::NoDebugify &&
244 if (!WrapWithDebugify) {
246 return;
247 }
248
249
250
251
252 PassKind Kind = P->getPassKind();
254
255
256 switch (Kind) {
262 OrigDIVerifyBugsReportFilePath));
263 break;
269 OrigDIVerifyBugsReportFilePath));
270 break;
271 default:
273 break;
274 }
275 }
276
277
279
281 DebugInfoBeforePass = &PerPassDI;
282 }
284 OrigDIVerifyBugsReportFilePath = BugsReportFilePath;
285 }
287 return OrigDIVerifyBugsReportFilePath;
288 }
289
291
293 return Mode == DebugifyMode::SyntheticDebugInfo;
294 }
296 return Mode == DebugifyMode::OriginalDebugInfo;
297 }
298
301};
302}
303
304#endif
This file provides a bitcode writing pass.
DebugifyMode
Used to check whether we track synthetic or original debug info.
llvm::ModulePass * createDebugifyModulePass(enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, llvm::StringRef NameOfWrappedPass="", DebugInfoPerPass *DebugInfoBeforePass=nullptr)
llvm::ModulePass * createCheckDebugifyModulePass(bool Strip=false, llvm::StringRef NameOfWrappedPass="", DebugifyStatsMap *StatsMap=nullptr, enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, DebugInfoPerPass *DebugInfoBeforePass=nullptr, llvm::StringRef OrigDIVerifyBugsReportFilePath="")
llvm::FunctionPass * createCheckDebugifyFunctionPass(bool Strip=false, llvm::StringRef NameOfWrappedPass="", DebugifyStatsMap *StatsMap=nullptr, enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, DebugInfoPerPass *DebugInfoBeforePass=nullptr, llvm::StringRef OrigDIVerifyBugsReportFilePath="")
llvm::FunctionPass * createDebugifyFunctionPass(enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, llvm::StringRef NameOfWrappedPass="", DebugInfoPerPass *DebugInfoBeforePass=nullptr)
This file contains an interface for creating legacy passes to print out IR in various granularities.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This file implements a map that provides insertion order iteration.
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM)
NewPMCheckDebugifyPass(bool Strip=false, llvm::StringRef NameOfWrappedPass="", DebugifyStatsMap *StatsMap=nullptr, enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, DebugInfoPerPass *DebugInfoBeforePass=nullptr, llvm::StringRef OrigDIVerifyBugsReportFilePath="")
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM)
NewPMDebugifyPass(enum DebugifyMode Mode=DebugifyMode::SyntheticDebugInfo, llvm::StringRef NameOfWrappedPass="", DebugInfoPerPass *DebugInfoBeforePass=nullptr)
A container for analyses that lazily runs them and caches their results.
DebugifyCustomPassManager wraps each pass with the debugify passes if needed.
bool isOriginalDebugInfoMode() const
void setOrigDIVerifyBugsReportFilePath(StringRef BugsReportFilePath)
void add(Pass *P) override
Add a pass to the queue of passes to run.
void setDebugInfoBeforePass(DebugInfoPerPass &PerPassDI)
const DebugifyStatsMap & getDebugifyStatsMap() const
void setDebugifyMode(enum DebugifyMode M)
DebugInfoPerPass & getDebugInfoPerPass()
void setDIStatsMap(DebugifyStatsMap &StatMap)
StringRef getOrigDIVerifyBugsReportFilePath() const
bool isSyntheticDebugInfo() const
bool isSyntheticDebugInfo() const
StringRef getOrigDIVerifyBugsReportFilePath() const
void setOrigDIVerifyBugsReportFilePath(StringRef BugsReportFilePath)
void setDebugifyMode(enum DebugifyMode M)
const DebugifyStatsMap & getDebugifyStatsMap() const
void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM)
DebugInfoPerPass & getDebugInfoPerPass()
bool isOriginalDebugInfoMode() const
void setDIStatsMap(DebugifyStatsMap &StatMap)
void setDebugInfoBeforePass(DebugInfoPerPass &PerPassMap)
FunctionPass class - This class is used to implement most global optimizations.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
StringRef - Represent a constant reference to a string, i.e.
A range adaptor for a pair of iterators.
PassManager manages ModulePassManagers.
void add(Pass *P) override
Add a pass to the queue of passes to run.
This is an optimization pass for GlobalISel generic memory operations.
bool applyDebugifyMetadata(Module &M, iterator_range< Module::iterator > Functions, StringRef Banner, std::function< bool(DIBuilder &, Function &)> ApplyToMF)
Add synthesized debug information to a module.
bool stripDebugifyMetadata(Module &M)
Strip out all of the metadata and debug info inserted by debugify.
void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map)
bool collectDebugInfoMetadata(Module &M, iterator_range< Module::iterator > Functions, DebugInfoPerPass &DebugInfoBeforePass, StringRef Banner, StringRef NameOfWrappedPass)
Collect original debug information before a pass.
bool checkDebugInfoMetadata(Module &M, iterator_range< Module::iterator > Functions, DebugInfoPerPass &DebugInfoBeforePass, StringRef Banner, StringRef NameOfWrappedPass, StringRef OrigDIVerifyBugsReportFilePath)
Check original debug information after a pass.
bool isIRPrintingPass(Pass *P)
Return true if a pass is for IR printing.
bool isBitcodeWriterPass(Pass *P)
Check whether a pass is a BitcodeWriterPass.
Used to track the Debug Info Metadata information.
WeakInstValueMap InstToDelete
Track how much debugify information (in the synthetic mode only) has been lost.
unsigned NumDbgValuesExpected
Number of dbg.values expected.
unsigned NumDbgLocsExpected
Number of instructions expected to have debug locations.
float getEmptyLocationRatio() const
Get the ratio of missing/expected instructions with locations.
unsigned NumDbgLocsMissing
Number of instructions with empty debug locations.
unsigned NumDbgValuesMissing
Number of missing dbg.values.
float getMissingValueRatio() const
Get the ratio of missing/expected dbg.values.
A CRTP mix-in to automatically provide informational APIs needed for passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...