summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-07-24 00:41:29 +0000
committerVedant Kumar <vsk@apple.com>2018-07-24 00:41:29 +0000
commitd6ff43cc71acde958d3927952a049f72e88fd79f (patch)
treeb7b43eb3873f317e98dca3c12ad4a0c6c5e60a60 /llvm/tools/opt/opt.cpp
parentca407c43364e4315f8ae32bd0c0e70c5aafb7962 (diff)
downloadbcm5719-llvm-d6ff43cc71acde958d3927952a049f72e88fd79f.tar.gz
bcm5719-llvm-d6ff43cc71acde958d3927952a049f72e88fd79f.zip
[Debugify] Export per-pass debug info loss statistics
Add a -debugify-export option to opt. This exports per-pass `debugify` loss statistics to a file in CSV format. For some interesting numbers on debug value loss during an -O2 build of the sqlite3 amalgamation, see the review thread. Differential Revision: https://reviews.llvm.org/D49003 llvm-svn: 337787
Diffstat (limited to 'llvm/tools/opt/opt.cpp')
-rw-r--r--llvm/tools/opt/opt.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 98ad700409c..6e287b6c0ab 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -217,6 +217,11 @@ static cl::opt<bool> DebugifyEach(
cl::desc(
"Start each pass with debugify and end it with check-debugify"));
+static cl::opt<std::string>
+ DebugifyExport("debugify-export",
+ cl::desc("Export per-pass debugify statistics to this file"),
+ cl::value_desc("filename"), cl::init(""));
+
static cl::opt<bool>
PrintBreakpoints("print-breakpoints-for-testing",
cl::desc("Print select breakpoints location for testing"));
@@ -267,34 +272,45 @@ static cl::opt<std::string>
cl::value_desc("filename"));
class OptCustomPassManager : public legacy::PassManager {
+ DebugifyStatsMap DIStatsMap;
+
public:
using super = legacy::PassManager;
void add(Pass *P) override {
+ // Wrap each pass with (-check)-debugify passes if requested, making
+ // exceptions for passes which shouldn't see -debugify instrumentation.
bool WrapWithDebugify = DebugifyEach && !P->getAsImmutablePass() &&
!isIRPrintingPass(P) && !isBitcodeWriterPass(P);
if (!WrapWithDebugify) {
super::add(P);
return;
}
+
+ // Apply -debugify/-check-debugify before/after each pass and collect
+ // debug info loss statistics.
PassKind Kind = P->getPassKind();
+ StringRef Name = P->getPassName();
+
// TODO: Implement Debugify for BasicBlockPass, LoopPass.
switch (Kind) {
case PT_Function:
super::add(createDebugifyFunctionPass());
super::add(P);
- super::add(createCheckDebugifyFunctionPass(true, P->getPassName()));
+ super::add(createCheckDebugifyFunctionPass(true, Name, &DIStatsMap));
break;
case PT_Module:
super::add(createDebugifyModulePass());
super::add(P);
- super::add(createCheckDebugifyModulePass(true, P->getPassName()));
+ super::add(createCheckDebugifyModulePass(true, Name, &DIStatsMap));
break;
default:
super::add(P);
break;
}
}
+
+ const DebugifyStatsMap &getDebugifyStatsMap() const { return DIStatsMap; }
};
static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
@@ -839,6 +855,9 @@ int main(int argc, char **argv) {
Out->os() << BOS->str();
}
+ if (DebugifyEach && !DebugifyExport.empty())
+ exportDebugifyStats(DebugifyExport, Passes.getDebugifyStatsMap());
+
// Declare success.
if (!NoOutput || PrintBreakpoints)
Out->keep();
OpenPOWER on IntegriCloud